Why we created this snippet?
There are a number of reasons why you might be looking for a snippet like this. We wrote the snippet originally after encountering an issue with a form not submitting if a user entered an incorrect email, even after correcting the mistake. There was a conflict between Gravity Forms preventing double submissions and the browser based support of HTML5 validation. Our fix was to disable HTML5 validation and rely on the Gravity Forms validation.
<?php | |
/** | |
* Gravity Wiz // Disable HTML5 Validation on Gravity Forms | |
* http://gravitywiz.com/disable-html5-validation-on-gravity-forms/ | |
*/ | |
add_filter( 'gform_form_tag', 'add_no_validate_attribute_to_form_tag' ); | |
function add_no_validate_attribute_to_form_tag( $form_tag ) { | |
return str_replace( '>', ' novalidate="novalidate">', $form_tag ); | |
} |
How do I get started?
- This will work with even Gravity Forms v1.0 but that’s no excuse not to be running the latest version.
- Already have a license? Download Latest Gravity Forms
- Need a license? Buy Gravity Forms
- Copy and paste the snippet into your theme’s functions.php file.
- Once you have installed the snippet, you’re good to go! This one’s plug and play.
If you use it and like it, let us know!
Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 32+ essential add-ons for Gravity Forms with support you can count on.
Just wanted to thank you for this post – although we didn’t use this snippet, it did push in the right direction to enabling the “Output HTML5” setting for our form. Much appreciated!
Glad to help, Chris!
Is there a benefit using this instead of ‘disable html5 output’ in the Gravity Forms settings?
It will have the same effect but disabling HTML5 also disables ALL HTML5 features, not just the HTML5 validation.
welp, this broke my site. It wasn’t clear that only part of it needed to be in the functions.php file. I mistakenly added all of it to the existing code. -__-
Hi Rob, it sounds like you’ve already got this fixed but if not, this will help: https://gravitywiz.com/documentation/snippet-troubleshooting/
Perfect little snippet! Thanks for this easy fix.
Glad you found it useful!
Where do i direct pre sale questions?
Hi Jermain,
There is a link on the Gravity Perks sales page to the pre sales form but for easy access, here you go! Question about Gravity Perks?