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
Submit button disabled until all form fields are valid. #1996
Comments
Found a solution to this problem? |
Same request... |
@harkinj @pashkes The closest I found so far is this: https://stackoverflow.com/a/27050178/3163075
I think it basically comes down to someone like @staabm who needs to implement this feature. |
The code below is what I ended up with so far: $('#formId').on('blur keyup change', 'input', function(event) {
validateForm('#formId');
});
function validateForm(id) {
var valid = $(id).validate().checkForm();
if (valid) {
$('.form-save').prop('disabled', false);
$('.form-save').removeClass('isDisabled');
} else {
$('.form-save').prop('disabled', 'disabled');
$('.form-save').addClass('isDisabled');
}
}
// Run once, so subsequent input will be show error message upon validation
validateForm('#formId'); It uses |
This issue/proposal has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up. |
Does anyone know a ability to disable the button while the form is invalid? We check the fields instantly after focus out of the specific field. |
It appears that there is no way to do such thing @it4need I ended also doing a custom code with the keyup event on each input to validate that. |
This has the effect of disabling the paypal buttons until basic validate passes. The goal here is to prevent the scenario where someone clicks on the paypal button, authorizes the payment and then has to re-authorize due to the form submission not being accepted. We REALLY don't want to take their authorization until the form is correct. Note that there is an api we could use (ContributionPage.validate ['action' => 'create', 'id' => x] I couldn't find any evidence of being able to listen to when a form is valid - posts like this jquery-validation/jquery-validation#1996 suggest the method I used. The easiest way to test this is by submitting the form as an anonymous user without entering an email - you should not be able to launch the paypal form and there should be red writing next to the field. Unfortunately without a core patch you will ALSO get an alert. I am proposing a core patch along side this which will suppress it in core. Really I think it would be best to put the message down by the paypal button (possibly hiding it) but because of the need to call it at the start it needs to be less nasty.
This has the effect of disabling the paypal buttons until basic validate passes. The goal here is to prevent the scenario where someone clicks on the paypal button, authorizes the payment and then has to re-authorize due to the form submission not being accepted. We REALLY don't want to take their authorization until the form is correct. Note that there is an api we could use (ContributionPage.validate ['action' => 'create', 'id' => x] This attempt #98 was against the previous version of paypal smartbuttons but it demonstrates the api I couldn't find any evidence of being able to listen to when a form is valid - posts like this jquery-validation/jquery-validation#1996 suggest the method I used. The easiest way to test this is by submitting the form as an anonymous user without entering an email - you should not be able to launch the paypal form and there should be red writing next to the field. Paypal documentation on it https://developer.paypal.com/docs/checkout/integration-features/validation/?mark=validat#synchronous-validation Note the async mode is BAD - it launches the modal & does the check while loading. Avoid. Perhaps we could only render the paypal button when valid - like they suggest - but then switching back & forth with valid & invalid gets hard. Am on the fence about hiding Unfortunately without a core patch you will ALSO get an alert. I am proposing a core patch along side this which will suppress it in core. Really I think it would be best to put the message down by the paypal button (possibly hiding it) but because of the need to call it at the start it needs to be less nasty.
Hi,
Great plug-in.
Is there a way of initially setting the Form Submit button to disabled and it is only enabled when all the forms fields have been successfully validated and hence are ready to be submitted?
I've looked through help and issues and have found nothing to do this and I'm guessing it would be a common use case.
Thanks for your time.
John
The text was updated successfully, but these errors were encountered: