Remote validation clears validationmessages of the fields above the field with remotecheck #517

Closed
11mb opened this Issue Sep 19, 2012 · 2 comments

Projects

None yet

2 participants

@11mb

First I added a comment on this thread: #12
But my situation is slightly different.

When I have a form with remote-validation and using async=false all errormessages of the fields above (in html) won't be shown.

I provided some sample code:
http://stackoverflow.com/questions/12475350/jquery-validate-remote-bug

You'll see that validation works when the remote-validation-field is the first field in the form.. but when moved to the end, no error messages but the one from the remote-check will be shown.

@11mb

I added the following answer on stackoverflow:

I found in jquery.validate.js (v1.10.0 - 9/7/2012) that in the showErrors function is called when all rules are validated and again invoked seperately when the remote-rule is finished.

When the remote-rule finishes and the showErrors function is called this.errorList will be reset. But at that point the this.errorList variable will contain the previous validation messages.

Commenting the this.errorList = []; will fix above problem. I don't know if it breaks anything else.

showErrors: function(errors) {
        if(errors) {
            // add items to error list and map
            $.extend( this.errorMap, errors );
            //this.errorList = [];
            for ( var name in errors ) {
                this.errorList.push({
                    message: errors[name],
                    element: this.findByName(name)[0]
                });
            }
            // remove items from success list
            this.successList = $.grep( this.successList, function(element) {
                return !(element.name in errors);
            });
        }
        if (this.settings.showErrors) {
            this.settings.showErrors.call( this, this.errorMap, this.errorList );
        } else {
            this.defaultShowErrors();
        }
    }
@11mb 11mb pushed a commit to 11mb/jquery-validation that referenced this issue Oct 15, 2012
@william-nedbase william-nedbase Fixed synchronised remote calls.
Fix as described in Issue #517.
- Removed line 385 this.errorList = [];

When using async=false remote-validation errormessages of the fields
above (in html) won't show up.
cc42ffc
@jzaefferer
Owner

I'm sorry for the lack of activity on this issue. Instead of leaving it open any longer, I decided to close old issues without trying to address them, to longer give the false impression that it will get addressed eventually.

To the reporter (or anyone else interested in this issue): If you're affected by the same issue, consider opening a new issue, with a testpage that shows the issue. Even better, try to fix the issue yourself, and improve the project by sending a pull request. This may seem daunting at first, but you'll likely learn some useful skills that you can apply elsewhere as well. And you can help keep this project alive. We've documented how to do these things, too. A patch is worth a thousand issues!

@jzaefferer jzaefferer closed this Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment