Javascript Reference - HTML DOM Button formNoValidate Property








The formNoValidate property sets or gets whether to validate the form-data on submission.

This property is only used for buttons with type="submit".

The formnovalidate attribute is added for the <button> element in HTML5.

Browser Support

formNoValidate Yes 10 Yes Yes Yes

Syntax

Return the formNoValidate property:

var v = buttonObject.formNoValidate

Set the formNoValidate property:

buttonObject.formNoValidate=true|false




Property Values

Value Description
true|false
  • true - No validate on the form-data
  • false - Default. Validate form-data

Return Value

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

Example

The following code shows how to find out if the form-data should be validated or not.


<!DOCTYPE html>
<html>
<body>
<!--from   www . ja  v a2  s.  com-->
<form action="url" method="get">
E-mail: <input type="email" name="userid"><br>
<button id="myBtn" type="submit" formnovalidate>Submit</button>
</form>

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

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

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

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to set the formNoValidate property.


<!DOCTYPE html>
<html>
<body>
<!--   w w w.  j  av  a  2  s .  c o m-->
<form action="url" method="get">
E-mail: <input type="email" name="userid"><br>
<button id="myBtn" type="submit" formnovalidate>Submit</button>
</form>
<button onclick="myFunction()">test</button>

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

<script>
function myFunction() {
    document.getElementById("myBtn").formNoValidate = false;
    document.getElementById("demo").innerHTML = "changed";
}
</script>

</body>
</html>

The code above is rendered as follows: