-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abide: Prevent refresh on submit #2874
Comments
I'm not seeing this issue you are referring to. The docs page successfully captures the submit event and keeps the data from submitting if the form is invalid. Can you post your implementation so I can take a look? Line 100 gets returned if the form is invalid, else line 110 gets returned. |
I have my form inside a reveal modal, maybe that is part of the problem. When I hit the submit button, leaving all input fields blank (thus an invalid form), the result is a page refresh. When I change that line 110 to false, it seems to work fine. |
I think that the problem here is that there is no way to stop the form from submitting if the form fields are all valid. For example, you may want to use AJAX to submit the form but still use Abide to validate the fields. |
I've found a solution here: http://stackoverflow.com/questions/18099407/preventdefault-not-working-with-zurb-validationabide You can stop the form from submitting by default, then check if it is valid before adding the desired functionality like so: $("#myForm").on("valid invalid submit", function(e){ |
I will give it a try. Another question about abide: Can you tell me if the automatic matching of input types with patterns also works with browsers that don't support HTML5? In other words, in case I use type="email" then I could leave out pattern="email" in the same element (whatever the browser)? |
I have pushed that makes Ajax submission easier. Now you can just set
|
Sorry but, i've this form inside a reveal
and this script code:
where cart-button is the id of a submit button of my store cart. Thankyou |
This should do the trick. |
Thank you, this works! |
+1 it works :) |
@mrsweaters |
is there a fix for this on foundation 6? |
Hi,
When the form is invalid a false is returned, if valid a true. This true makes the page refresh which I don't like. Therefore I suggest this change:
File: foundation.abide.js
Line: 110
Change: return false; // this prevents the page refreshing.
Best,
Boah
The text was updated successfully, but these errors were encountered: