user-input

Disable Text Entry in <input type=“number”>

一世执手 提交于 2019-11-27 16:24:21
问题 I am making a simple web app. At one part of it, I have included an input box of type="number" <input type="number" min="0"> Anyhow, when I run the code in my latest Google Chrome Browser, I am able to enter text too: I do not want users to be able to do that. How should I rectify this? 回答1: You can use JavaScript (e.g. with jQuery) to allow only specific characters: // Catch all events related to changes $('#textbox').on('change keyup', function() { // Remove invalid characters var sanitized

how to get input from user at runtime

你离开我真会死。 提交于 2019-11-27 16:23:42
问题 i want to take runtime input from user in oracle 10g pl/sql blocks(i.e. interactive communication with user), is it possible? declare x number; begin x=&x; end this code gives error as & can't be used in oracle 10g. 回答1: To read the user input and store it in a variable, for later use, you can use sqlplus command ACCEPT . Accept <your variable> <variable type if needed [number|char|date]> prompt 'message' example accept x number prompt 'Please enter something: ' And then you can use the x

Commas messing with number input in Javascript

╄→尐↘猪︶ㄣ 提交于 2019-11-27 14:35:51
I have a page with some elements that are controlled by the user. One of these is a text input field, where the user is supposed to input a number. Everything works well if the user only inputs digits (EG 9000), but is the user uses comma notation (the being 9,000) javascript doesn't take the input as an integer. How can I remove the commas and/or force the input to an integer? I tried using parseint(), but it doesn't seem to work with commas. Use a global regular expression to replace all commas with an empty string: var str = "12,345,678"; str = str.replace(/,/g, ""); parseInt(str, 10);

Simple InputBox function

纵然是瞬间 提交于 2019-11-27 13:51:56
问题 I'm aware of a simple pop-up function for PowerShell, e.g.: function popUp($text,$title) { $a = new-object -comobject wscript.shell $b = $a.popup($text,0,$title,0) } popUp "Enter your demographics" "Demographics" But I am unable to find an equivalent for getting a pop-up to ask for input. Sure, there is Read-Line, but it prompts from the console. And then there is this complex function, which seems overkill for a script that will ask for input once or twice: function getValues($formTitle,

DataInputStream deprecated readLine() method

☆樱花仙子☆ 提交于 2019-11-27 13:31:59
问题 I am on java 6. Using DataInputStream in = new DataInputStream(System.in); to read user input. When the readLine() is deprecated. What is the work around for reading user value? DataInputStream in = new DataInputStream(System.in); int num; try { num = Integer.parseInt(in.readLine()); //this works num = Integer.parseInt(in); //just in doesnt work. } catch(Exception e) { } please explain as it should when the readLine() is deprecated. 回答1: InputStream is fundamentally a binary construct. If you

How does jsFiddle allow and execute user-defined JavaScript without being dangerous?

好久不见. 提交于 2019-11-27 13:06:46
问题 I've been working on a JS library and would like to setup a demo page on Github that allows, for example, users to define their own callbacks and execute commands. I know " eval() is evil" and I can see how blind eval() of scripts could lead to XSS and other security issues. I'm trying to cook up some alternative schemes. I really enjoy the interactivity of jsFiddle. I've taken a look at their source but was hoping someone could lay out here how jsFiddle allows and executes user-defined

Why can't I enter a string in Scanner(System.in), when calling nextLine()-method?

南楼画角 提交于 2019-11-27 12:56:42
How does this program actually work...? import java.util.Scanner; class string { public static void main(String a[]){ int a; String s; Scanner scan = new Scanner(System.in); System.out.println("enter a no"); a = scan.nextInt(); System.out.println("no is ="+a); System.out.println("enter a string"); s = scan.nextLine(); System.out.println("string is="+s); } } The output is: enter the no 1234 no is 1234 enter a string string is= //why is it not allowing me to enter a string here? .nextInt() gets the next int , but doesn't read the new line character. This means that when you ask it to read the

When is it best to sanitize user input?

▼魔方 西西 提交于 2019-11-27 12:00:54
User equals untrustworthy. Never trust untrustworthy user's input. I get that. However, I am wondering when the best time to sanitize input is. For example, do you blindly store user input and then sanitize it whenever it is accessed/used, or do you sanitize the input immediately and then store this "cleaned" version? Maybe there are also some other approaches I haven't though of in addition to these. I am leaning more towards the first method, because any data that came from user input must still be approached cautiously, where the "cleaned" data might still unknowingly or accidentally be

How to Test Character Input to UITextField as the User Enters Characters and Prevent Invalid Characters

∥☆過路亽.° 提交于 2019-11-27 11:43:55
First, I setup up the keyboard for the UITextField to use the number with decimal style. So the user can only enter numbers and a single decimal. What I want to do is test the input as the user enters it and prevent multiple decimals from being entered and limit the decimal portion of the number to two places. I do not want to round off the number nor even treat the input as a number. I simply want to prevent the user from entering more then two digits to the right of the decimal place. The solution ultimately turned out to be fairly trivial. Unfortunately a lot of the questions and answers

“Safe” markdown processor for PHP?

亡梦爱人 提交于 2019-11-27 09:21:47
问题 Is there a PHP implementation of markdown suitable for using in public comments? Basically it should only allow a subset of the markdown syntax (bold, italic, links, block-quotes, code-blocks and lists), and strip out all inline HTML (or possibly escape it?) I guess one option is to use the normal markdown parser, and run the output through an HTML sanitiser, but is there a better way of doing this..? We're using PHP markdown Extra for the rest of the site, so we'd already have to use a