User Input is data that the user inputs into the program. It generally takes the form of a String, but may also be an integer, floating-point number, etc.
Questions tagged [user-input]
5580 questions
1265
votes
16 answers
How can I sanitize user input with PHP?
Is there a catchall function somewhere that works well for sanitizing user input for SQL injection and XSS attacks, while still allowing certain types of HTML tags?

Brent
- 23,354
- 10
- 44
- 49
378
votes
6 answers
Getting a hidden password input
You know how in Linux when you try some Sudo stuff it tells you to enter the password and, as you type, nothing is shown in the terminal window (the password is not shown)?
Is there a way to do that in Python? I'm working on a script that requires…

Nacht
- 10,488
- 8
- 31
- 39
252
votes
21 answers
How to show "Done" button on iOS number pad keyboard?
There is no "Done" button on the .numberPad Keyboard Type. When a user finishes entering numeric information in a text field, how can I make the number pad disappear?
I could get a "Done" button by using the default keyboard, but then users would…

Chilly Zhong
- 16,763
- 23
- 77
- 103
240
votes
18 answers
Password masking console application
I tried the following code...
string pass = "";
Console.Write("Enter your password: ");
ConsoleKeyInfo key;
do
{
key = Console.ReadKey(true);
// Backspace Should Not Work
if (key.Key != ConsoleKey.Backspace)
{
pass +=…

Mohammad Nadeem
- 9,134
- 14
- 56
- 82
223
votes
20 answers
How do you implement a good profanity filter?
Many of us need to deal with user input, search queries, and situations where the input text can potentially contain profanity or undesirable language. Oftentimes this needs to be filtered out.
Where can one find a good list of swear words in…

Ben Throop
- 4,772
- 5
- 23
- 20
215
votes
8 answers
std::cin input with spaces?
#include
std::string input;
std::cin >> input;
The user wants to enter "Hello World". But cin fails at the space between the two words. How can I make cin take in the whole of Hello World?
I'm actually doing this with structs and…

dukevin
- 22,384
- 36
- 82
- 111
175
votes
17 answers
JavaScript: Check if mouse button down?
Is there a way to detect if a mouse button is currently down in JavaScript?
I know about the "mousedown" event, but that's not what I need. Some time AFTER the mouse button is pressed, I want to be able to detect if it is still pressed down.
Is…

TM.
- 108,298
- 33
- 122
- 127
164
votes
7 answers
Spring MVC: How to perform validation?
I would like to know what is the cleanest and best way to perform form validation of user inputs. I have seen some developers implement org.springframework.validation.Validator. A question about that: I saw it validates a class. Does the class have…

devdar
- 5,564
- 28
- 100
- 153
144
votes
5 answers
Getting user input
I am running this:
import csv
import sys
reader = csv.reader(open(sys.argv[0], "rb"))
for row in reader:
print row
And I get this in response:
['import csv']
['import sys']
['reader = csv.reader(open(sys.argv[0]', ' "rb"))']
['for row in…

Alex Gordon
- 57,446
- 287
- 670
- 1,062
97
votes
7 answers
JUnit testing with simulated user input
I am trying to create some JUnit tests for a method that requires user input. The method under test looks somewhat like the following method:
public static int testUserInput() {
Scanner keyboard = new Scanner(System.in);
…

Wimpey
- 1,081
- 1
- 8
- 5
89
votes
9 answers
Disadvantages of scanf
I want to know the disadvantages of scanf().
In many sites, I have read that using scanf might cause buffer overflows. What is the reason for this? Are there any other drawbacks with scanf?

karthi_ms
- 5,568
- 11
- 38
- 39
85
votes
17 answers
How to read multiple lines of raw input?
I want to create a Python program which takes in multiple lines of user input. For example:
This is a multilined input.
It has multiple sentences.
Each sentence is on a newline.
How can I take in multiple lines of raw input?

felix001
- 15,341
- 32
- 94
- 121
81
votes
7 answers
How to define default value if empty user input in Python?
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…

lkkkk
- 1,999
- 4
- 23
- 29
67
votes
14 answers
When is it best to sanitize user input?
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…

Aaron
- 23,450
- 10
- 49
- 48
67
votes
6 answers
Hide input on command line
I know that command line interfaces like Git and others are able to hide input from a user (useful for passwords). Is there a way to programmtically do this in Java? I'm taking password input from a user and I would like their input to be "hidden"…

kentcdodds
- 27,113
- 32
- 108
- 187