Javascript Reference - HTML DOM Form noValidate Property








The noValidate property turns off or on the form validation on submission.

Browser Support

noValidate Yes 10.0 Yes Yes Yes

Syntax

Return the noValidate property.

var v = formObject.noValidate

Set the noValidate property.

formObject.noValidate=true|false

Property Values

Value Description
true|false Turn on or off form-data validation on submission
  • true - The form-data should not be validated
  • false - The form-data should be validated




Return Value

A Boolean type value, true if the form-data should not be validated, otherwise false.

Example

The following code shows how to set the noValidate property.


<!DOCTYPE html>
<html>
<body>
<!--  w ww . j av  a  2  s .  c o  m-->
<form id="myForm" action="url">
  E-mail: <input type="email" name="user_email">
  <input type="submit">
</form>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    document.getElementById("myForm").noValidate = true;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get if the form-data should be validated.


<!DOCTYPE html>
<html>
<body>
<!--from   w  w w . jav a2  s. c om-->
<form id="myForm" action="url" novalidate>
  E-mail: <input type="email" name="user_email">
  <input type="submit">
</form>
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myForm").noValidate;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: