The type
property returns the type of a text field.
The type property is supported in all major browsers.
type |
Yes | Yes | Yes | Yes | Yes |
var v = textObject.type
A String type value representing the type of the text field.
The following code shows how to get the type of the text field.
<!DOCTYPE html>
<html>
<body>
<!-- w ww.ja v a2 s. c om-->
Name: <input type="text" id="myText" value="abc">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myText").type;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: