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

Javascript examples for DOM HTML Element:Input Number

Description

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form action="#">
  Number: <input type="number" id="myNumber" name="quantity">
  <input type="submit">
</form>//from ww  w . j ava2 s .  c o  m

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

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

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

</body>
</html>

Related Tutorials