Input Text type Property - Javascript DOM HTML Element

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".

Return Value

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:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
Name: <input type="text" id="myText" value="Mary">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {// w ww . j ava  2  s.c  o  m
    var x = document.getElementById("myText").type;
    document.getElementById("demo").innerHTML = x;


Related Tutorials