Questions tagged [user-input]

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.

5580 questions
18
votes
4 answers

Fill os.Stdin for function that reads from it

How do I fill os.Stdin in my test for a function that reads from it using a scanner? I request a user command line input via a scanner using following function: func userInput() error { scanner := bufio.NewScanner(os.Stdin) println("What is…
Wulthan
  • 417
  • 2
  • 6
  • 19
18
votes
5 answers

bash: choose default from case when enter is pressed in a "select" prompt

I'm prompting questions in a bash script like this: optionsAudits=("Yep" "Nope") echo "Include audits?" select opt in "${optionsAudits[@]}"; do case $REPLY in 1) includeAudits=true; break ;; 2)…
joniba
  • 3,339
  • 4
  • 35
  • 49
18
votes
4 answers

XSS Torture Test - does it exist?

I'm looking to write a html sanitiser, and obviously to test/prove that it works properly, I need a set of XSS examples to pitch against it to see how it performs. Here's a nice example from Coding Horror
JamShady
  • 2,914
  • 1
  • 21
  • 22
18
votes
3 answers

What is the proper way to handle an incorrect directory path taken as user input?

Below is a snippet of code I am trying to use to take a directory path as "raw input" from the user. I receive the following error after the input is taken from the user: Traceback (most recent call last): File…
mrokeowo
  • 203
  • 1
  • 2
  • 5
18
votes
5 answers

Fix a character to text input box using javascript/jquery

I am looking for a way to 'fix' a dollar symbol $ to a text input box eg but make it not possible for the default value to be removed, so that whatever the user inputs, there is always a $ symbol 'prepending'…
Eddie
  • 235
  • 1
  • 4
  • 8
18
votes
4 answers

How do I drop a pin with MapKit?

I would like to allow the user of my app to pick a location in the map. The native map has a "drop pin" feature where you can locate something by dropping a pin. How can I do this in MapKit?
erotsppa
  • 14,248
  • 33
  • 123
  • 181
18
votes
6 answers

Lua - get command line input from user?

In my lua program, i want to stop and ask user for confirmation before proceeding with an operation. I'm not sure how to stop and wait for user input, how can it be done?
RCIX
  • 38,647
  • 50
  • 150
  • 207
17
votes
4 answers

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

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…
MysticBrook
17
votes
8 answers

'Advanced' Console Application

I'm not sure if this question has been answered elsewhere and I can't seem to find anything through google that isn't a "Hello World" example... I'm coding in C# .NET 4.0. I'm trying to develop a console application that will open, display text,…
keynesiancross
  • 3,441
  • 15
  • 47
  • 87
17
votes
7 answers

C# arrow key input for a console app

I have a simple console app written in C#. I want to be able to detect arrow key presses, so I can allow the user to steer. How do I detect keydown/keyup events with a console app? All my googling has led to info about windows Forms. I don't have…
Tim
  • 8,912
  • 3
  • 39
  • 57
17
votes
7 answers

HTML input that takes only numbers and the + symbol

I am trying to build a custom text input for phone numbers that accepts only numbers and the plus (+) symbol; all other characters need to be discarded and not shown on the field. I am trying to do this using an event handler (onkeydown/onkeypress)…
unpollito
  • 937
  • 1
  • 11
  • 30
17
votes
3 answers

Why does my string not match when reading user input from stdin?

I'm trying to get user input and check if the user put in "y" or "n". Surprisingly, in the below code, neither the if nor the if else case executes! Apparently, correct_name is neither "y" nor "n". How can that be? Am I doing my string conversion…
Joe
  • 355
  • 3
  • 8
17
votes
10 answers

PHP - HTML Purifier - hello wrld/world tutorial striptags

I am just looking into using HTML Purifier to ensure that a user-inputed string (that represents the name of a person) is sanitized. I do not want to allow any html tags, script, markup etc - I just want the alpha, numeric and normal punctuation…
JW.
  • 4,821
  • 5
  • 43
  • 60
17
votes
2 answers

Is it safe to use user's RegEx?

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);
Sdgsdg Asgasgf
  • 205
  • 2
  • 6
16
votes
4 answers

Escaping user input from database necessary?

So I know about MySQL injection and always escape all my user input before putting it in my database. However I was wondering, imagine a user tries to submit a query to inject, and I escape it. What if I then at a later moment take this value from…
Kokos
  • 9,051
  • 5
  • 27
  • 44