how to get textbox value in javascript
In this tutorial, we will explain to you how to get textbox value in javascript. you can easily get the textbox value after the button click event or change event.
in this example we are getting the textbox value using the javascript. we will get value using the particular element object. so here for get value, we are use getElementById() or getElementsByClassName().
So you can see below our example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <!DOCTYPE html> <html> <head> <title>how to get textbox value in javascript - XpertPhp</title> <script type="text/javascript"> function myFunction(){ var name = document.getElementById("name").value; alert(name); } </script> </head> <body> <form action="" method=""> <label>Name :-</label> <input type="text" name="name" placeholder="Enter Name" id="name"> <button type="button" onclick="myFunction();">Click</button> </form> </body> </html> |
Read Also
How To Check File Size Before Upload In Javascript
How To Remove Empty Object From JSON In JavaScript
Allow Only Numbers In Textbox Javascript Onkeypress
Please follow and like us: