Javascript examples for DOM HTML Element:Input Text
The type property returns the type of form text field.
For a text field, this property returns "text".
Type | Description |
---|---|
String | The type of form element the text field is |
The following code shows how to check which type of form element the text field is:
<!DOCTYPE html> <html> <body> Name: <input type="text" id="myText" value="Mary"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w ww . j ava 2 s.c o m var x = document.getElementById("myText").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>