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. so we will give you a simple example of a javascript get input value.
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 use getElementById() or getElementsByClassName().
As you can see below our example.
<!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>
Please follow and like us: