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.
formNoValidate |
Yes | 10 | Yes | Yes | Yes |
Return the formNoValidate property:
var v = buttonObject.formNoValidate
Set the formNoValidate property:
buttonObject.formNoValidate=true|false
Value | Description |
---|---|
true|false
|
A Boolean, returns true if the form-data should not be validated, otherwise it returns false.
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:
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: