Input URL required Property - Set a URL field to be a required part of form submission: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input URL

Description

Input URL required Property - Set a URL field to be a required part of form submission:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
  Homepage: <input type="url" id="myURL" name="website">
  <input type="submit">
</form>/*from w  ww  . j  a  v a2  s  .  com*/

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

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

<script>
function myFunction() {
    document.getElementById("myURL").required = true;
    document.getElementById("demo").innerHTML = "The required property was set.";
}
</script>

</body>
</html>

Related Tutorials