0

How to get an input from user in JavaScript?

21st Sep 2016, 4:46 AM
Rahul Aery
Rahul Aery - avatar
5 Answers
+ 3
Use an html input.
21st Sep 2016, 7:38 AM
Zen
Zen - avatar
+ 1
You can use the prompt function Copy this code snippet & paste it between the body tags of your web page <script> /*get input from user*/ window.prompt("Please enter your value","please put your value here"); </script> Have Fun :)
5th Nov 2016, 6:18 PM
Mohammed Omran
Mohammed Omran - avatar
+ 1
you can use html form tag simply and use Javascript for form validation. this is a standard way to getting input from users
12th Nov 2016, 4:57 PM
Ankit Mishra
Ankit Mishra - avatar
0
Thanks, I tried Prompt earlier but it is only good for single values. Thanks.
21st Sep 2016, 7:42 AM
Rahul Aery
Rahul Aery - avatar
0
is it from a registration form or what? if so them you have to give your form inputs ids and then call them: var fname = document.getElementById ('fname'); var jsInput; fname.onchange = function (){ if (fname.value !== ""){ jsInput = fname.value; } good luck
28th Sep 2016, 10:39 PM
Lukwago
Lukwago - avatar