Javascript DOM HTML Button formNoValidate Property get

Introduction

Find out if the form-data should be validated:

var x = document.getElementById("myBtn").formNoValidate;

Click the button to find out if the form-data should be validated or not, on submission.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php" method="get">
  E-mail: <input type="email" name="userid"><br>
  <button id="myBtn" type="submit" formnovalidate>Submit</button>
</form>/*from   w  w w . j a va  2  s.  c  om*/

<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 formNoValidate property sets or gets whether the form-data should be validated on submission.

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

When set to true, this property adds the "formnovalidate" attribute to the "submit" button.

It sets that the form-data should not be validated on submission.

This overrides the form's novalidate attribute.

The formNoValidate property accepts and returns a boolean type value.

Value Description
true The form-data should not be validated
false Default. The form-data should be validated

The formNoValidate property returns true if the form-data should not be validated, otherwise it returns false




PreviousNext

Related