How to specify that the form should not be validated when disabled in HTML?

HTMLWeb DevelopmentFront End Technology

In HTML, forms for user input are created using the <form> tag. The form tag uses a lot of different elements. When submitting a form, the novalidate attribute of the HTML <form> tag is used to indicate that the form-data should not be validated. This attribute is a Boolean one.

Following are the examples…

Example

In the following example we are using novalidate to make the form disabled after getting submitted.

<!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

On executing the above script, the window will open up and display the input field along with a submit button. When clicked on the submit button, it will open in a new tab without any change because of the nonvalidated form.

Example

Another example to explain the novalidate attribute is shown below −

<!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

On executing the above script, the window will open up and display the input fields student name and rank along with a submit button. When the submit button is clicked, it will open a new tab without any change because of the nonvalidated form.

raja
Updated on 06-Sep-2022 07:39:45

Advertisements