0
How to get an input from user in JavaScript?
5 Answers
+ 3
Use an html input.
+ 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 :)
+ 1
you can use html form tag simply and use Javascript for form validation. this is a standard way to getting input from users
0
Thanks, I tried Prompt earlier but it is only good for single values. Thanks.
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