Javascript DOM HTML Input URL type Property get

Introduction

Return which type of form element the URL field is:

var x = document.getElementById("myURL").type;

Click the button to return which type of form element the URL field is.

elements with type="url" are not supported in Safari.

View in separate window

<!DOCTYPE html>
<html>
<body>

Homepage: <input type="url" id="myURL">

<button onclick="myFunction()">Test</button>
<p id="demo"></p>
<script>
function myFunction() {//from ww  w  . j a v  a  2  s  . c o m
  var x = document.getElementById("myURL").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element the URL field is.

For an input type="url", this property will always return "url".




PreviousNext

Related