formnovalidate and formtarget Attribute in HTML5

April 05, 2014
On this page we will learn formnovalidate and formtarget input attributes introduced in HTML5. HTML5 provides many interesting input attributes that can reduce the scripting coding burden of UI developers. We will discuss and provide demo for these two attributes separately. Examples given in the program will run on HTML5 supporting browser.

"formnovalidate" Attribute in HTML5

The HTML5 formnovalidate attribute allows us to submit a form without validation. If we have created a form which contains such input types which forces to validate field, but still we want a submit button which will submit form without validation. To fulfill this require there is one input attribute formnovalidate in HTML5. Juts use it in the input type submit and you are done. Check the example how to use it.
<!DOCTYPE html>
<html>
<body>
<h4>formnovalidate Demo in HTML5</h4>
<form action="" >
   Email: <input type="email" name="email"><br>
  <br/><input type="submit" value="Submit">
  <input type="submit" value="Submit without Validate"  formnovalidate>
</form>
</body>
</html> 

In the example there is email input type. The property of email input type is that it forces the field validation for valid email entry. There is two submit button in the example, one is normal that will follow email validation and second one will allow submitting form without validation. Enter invalid email id input and test.

"formtarget" Attribute in HTML5

The HTML5 attribute formtarget will allow us to submit form in required window. Before HTML5, if we need to submit form in different window, we need to set target property in form level. Now we can do it at button level. So there can be more than one button and one will submit in parent window and second can submit in different window. Find the example.
<!DOCTYPE html>
<html>
<body>
<h4>formtarget Demo in HTML5</h4>
<form action="" >
    First Name: <input type="text" name="fname"><br>
	Last Name: <input type="text" name="lname">
  <br/><input type="submit" value="Submit">
  <input type="submit" value="Submit in New Window"  formtarget="_blank">
</form>
</body>
</html> 

Test now.







©2024 concretepage.com | Privacy Policy | Contact Us