Skip to content
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

Form validation is bypassed if any exceptions within custom callback #217

Open
christoferd opened this issue Mar 18, 2019 · 0 comments
Open

Comments

@christoferd
Copy link

christoferd commented Mar 18, 2019

Form submits with errors after a validation.

Issue: For some reason this library does not perform validation correctly whenever classes are added to the form input elements.
Update: I have found out that if there are any exceptions thrown from within the custom callback function, the form will submit and bypass the validation!

Further issue:

Scenario:
I have setup validation options with the second argument, the callback function.

What makes this very difficult to solve is that the validator ignores the exception, does not report to console.log and continues to redirect the user to the next page. 👎

What I suggest to improve this, and help people avoid this issue:
In the example documentation, update to something like this:

    // Validation Configuration
    var validator = new FormValidator('myFormId', [
        // ...
        // validation settings
        // ...
    ], function (errors, event) {
        try {
            // Custom code goes here
        } catch (ex) {
            // This is displayed if any major errors occur in the custom code
            console.error('** ERROR IN FORM VALIDATION CALLBACK FUNCTION **');
            console.error(ex);
        }
    });
@christoferd christoferd changed the title Form allows submit on error within custom callback Form validation is bypassed if any exceptions within custom callback Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant