Home  >  Article  >  Web Front-end  >  In HTML, how to specify that a form does not validate when in the disabled state?

In HTML, how to specify that a form does not validate when in the disabled state?

WBOY
WBOYforward
2023-08-29 23:05:091373browse

In HTML, how to specify that a form does not validate when in the disabled state?

In HTML, forms for user input are created using the

tag. Form tags use many different elements. When a form is submitted, the
novalidate attribute of the HTML tag is used to indicate that the form data should not be validated. This property is a boolean value.

The following are examples...

Example

In the example below, we use novalidate to make the form disabled after submission.

<!DOCTYPE html>
<html>
<body style="text-align:center;">
   <form action="#" method="get"
      target="_self" novalidate>
      Name:
      <input type="text">
      <input type="submit" id="tutorials"
      name="mytutorials"
      value="Submit@tutorialspoint"
      formTarget="_blank">
   </form>
</body>
</html>

Output

When the above script is executed, the window will open and display the input fields as well as the submit button. When the submit button is clicked, it opens in a new tab and no changes will occur since the form is not validated.

Example

Another example to explain the novalidate attribute is as follows -

<!DOCTYPE html>
<html>
<head>
   <title>HTML novalidate attribute</title>
</head>
<body>
   <form action = "" method = "get" novalidate>
      Student Name<br><input type = "name" name = "sname"><br>
      Rank<br><input type = "number" name = "rank"><br>
      <input type = "submit" value = "Submit">
   </form>
</body>
</html>

Output

When the above script is executed, a window will open and display the input fields students name and rank and a submit button. When the submit button is clicked, since the form is not validated, it opens a new tab without any changes.

The above is the detailed content of In HTML, how to specify that a form does not validate when in the disabled state?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete