user-input

keep user-generated content from breaking layout?

試著忘記壹切 提交于 2019-12-22 05:19:17
问题 I have a site that wraps some user-generated content, and I want to be able to separate the markup for the layout, and the markup from the user-generated content, so the u-g content can't break the site layout. The user-generated content is trusted, as it is coming from a known group of users on my network, but nonetheless only a small subset of html tags are allowed (p, ul/ol/li, em, strong, and a couple more). However, the user-generated content is not guaranteed to be well-formed, and we

Angular 2 Custom Validator: check if the input value is an integer?

ぐ巨炮叔叔 提交于 2019-12-22 04:31:26
问题 In an Angular2 project I need to validate some inputs. How to easily check if an input value is an integer? I tried using Number(control.value) which returns 0 for an empty field - not good. or parseInt(control.value,10) which dis-considers spaces: If i have something like: 1 space 0,24 = 1 ,024 it returns 1 - which passes the validator with no errors. Lodash functions like: _.isInteger(control.value) or _.isNumeric(control.value) // return false every time -which is expected, because an

Angular 2 Custom Validator: check if the input value is an integer?

戏子无情 提交于 2019-12-22 04:31:04
问题 In an Angular2 project I need to validate some inputs. How to easily check if an input value is an integer? I tried using Number(control.value) which returns 0 for an empty field - not good. or parseInt(control.value,10) which dis-considers spaces: If i have something like: 1 space 0,24 = 1 ,024 it returns 1 - which passes the validator with no errors. Lodash functions like: _.isInteger(control.value) or _.isNumeric(control.value) // return false every time -which is expected, because an

Ruby .gets doesn't work

◇◆丶佛笑我妖孽 提交于 2019-12-21 20:57:22
问题 I'm trying to get simple user input in Ruby, but I can't get it working. I'm using the gets method, but the program never stops to ask me for input. I'm using Sublime Text 2 as my text editor, and I run the program in it, too (if this makes a difference). Here's my code: puts "What is your name?" name = gets puts "Hello " + name + ". How are you?" And here's the error (and output) given to me: C:/Users/Sten Sootla/Desktop/Ruby workspace/exercise.rb:3:in `+': can't convert nil into String

Is it safe to use user's RegEx?

人走茶凉 提交于 2019-12-21 07:01:26
问题 I want to add a feature to my website to let users search the texts with RegEx . But, is it safe to let the users do something like that ? preg_match('/' . $user_input_regex . '/', $subject); 回答1: There is a possible attack on this code called a ReDoS attack (Regular expression Denial of Service). The Regular expression Denial of Service (ReDoS) is a Denial of Service attack, that exploits the fact that most Regular Expression implementations may reach extreme situations that cause them to

Get user input from form, write to text file using php

浪子不回头ぞ 提交于 2019-12-21 05:13:06
问题 As part of a subscriber acquisition I am looking to grab user entered data from a html form and write it to a tab delimited text file using php.The data written needs to be separated by tabs and appended below other data. After clicking subscribe on the form I would like it to remove the form and display a small message like "thanks for subscribing" in the div. This will be on a wordpress blog and contained within a popup. Below are the specific details. Any help is much appreciated. The

Stop Submit With Empty Input Values

半城伤御伤魂 提交于 2019-12-21 04:52:24
问题 Im Looking for a simple solution to stop a login form from submitting with empty input fields. The code for the form is below. I would like to use a simple Javascript soluiton if possible. <form id="login" method="post" action=""> <input type="text" name="email" id="email" /> <input type="password" name="pwd" id="pwd" /> <button type="submit" id="submit">Login</button> </form> If possible I would also like to change the border of the empty field(s). Thanks in advance. 回答1: Sample code with

Default values on empty user input

拈花ヽ惹草 提交于 2019-12-20 09:48:43
问题 Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value will be assigned to a variable input after entering the value and hitting Enter . Is there any method that if we don't enter the value and directly hit the Enter key, the variable will be directly assigned to a default value, say as input = 0.025 ? 回答1: input = int(raw_input("Enter the inputs : ") or

How to get user confirmation in fish shell?

邮差的信 提交于 2019-12-20 09:39:51
问题 I'm trying to gather user input in a fish shellscript, particularly of the following oft-seen form: This command will delete some files. Proceed (y/N)? After some searching around, I am still not sure how to do this cleanly. Is these a special way of doing this in fish? 回答1: The best way I know of is to use the builtin read . If you are using this in multiple places you could create this helper function: function read_confirm while true read -l -P 'Do you want to continue? [y/N] ' confirm

How to capture enter key being pressed on pages containing multiple forms?

痴心易碎 提交于 2019-12-20 09:01:15
问题 I have inherited a web application where the usual ability to press return in any of the input fields has been disabled for the very good reason that the page contains multiple forms, and the application would not be able to determine (or, so I am told) which form to action. The application has been designed so there are no submit buttons (as in input type="submit") and, instead, the designers have gone for onclick handling. Here are two buttons that are defined on one of the pages, included