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

Ajax Field/Form Validation #502

Closed
rjhilgefort opened this issue Oct 9, 2012 · 13 comments
Closed

Ajax Field/Form Validation #502

rjhilgefort opened this issue Oct 9, 2012 · 13 comments

Comments

@rjhilgefort
Copy link

I am attempting to implement an ajax validation on a particular field in a form.

I seem to have gotten it working for the most part, ie- I am seeing the validator return "OK" when expected, and throw an error when expected. However, I am unable to successfully submit the form... in all cases. Even when the value has been validated successfully, the form submission will continue to say that the ajax validated field is invalid.

My implementation is quite cumbersome to recreate (in a working way), but I would be happy to try and post all relevant code. I just thought I would describe the issue first to see if there was something obvious I might be missing. Thank you in advance for your reply.

@rjhilgefort
Copy link
Author

I've been trying to debug the issue and have discovered that the issue stems from line 328 (in the _validateFields method). In case the line number has changed since I pulled down the plugin (last week), I am specifically referring to this line:

errorFound |= methods._validateField(field, options);

Here I am finding that _validateField() is returning that there is an errorFound, thus making the form invalid. I have not been able to track down why yet. As I said before, the inline ajax call validates on blur (shows green message), but that same field fails the submit validation.

Any help with this issue would be greatly appreciated. I would like to implement ajax validation all over my forms, but do not want to press on without solving this issue.

@rjhilgefort
Copy link
Author

I'll try to provide some additional information as I continue to try and debug this, but I would really appreciate some help. Let me know if there's any other information I can provide about the issue. Thanks again.

@tzarger
Copy link

tzarger commented Oct 10, 2012

Code might be helpful for anyone here to give it a look and see if anything obvious.

@rjhilgefort
Copy link
Author

I have traced it further and found that the below block is returning the loading message and seeing that as an error. I have tried to set "var isAjaxValidator = true;" and that has allowed me to somewhat bypass the error.

case "ajax":
    // AJAX defaults to returning it's loading message
    errorMsg = methods._ajax(field, rules, i, options);
    if (errorMsg) {
        promptType = "load";
    }
    break;

As far as I can tell, this appears to be a bug. The loading message should not be returned as an error message, right? At least, if it is returned so that it can be shown in the form, it should not trigger the form to be invalid.

I can start showing some code, just let me know which part of the set up you would like to see. I can't really set up a jsFiddle to recreate this error.

@posabsolute
Copy link
Owner

hi @rjhilgefort,
Sorry to be a bit late at taking a stab at your bug, there is a couple of hards one currently

just to understand clearly, after you use the ajax validation stuff, you can't submit the form?

Just a heads up, you can recreate this functionnality with a bit more of control using onValidationComplete, and after use an ajax call to validate the stuff on your side.

@rjhilgefort
Copy link
Author

I have the form in a jQuery UI modal (for whatever that's worth). When the user enters a value into the field and then focuses away from the field, the inline ajax validation is triggered and returns what I would expect, validation wise. Everything is working fine up to this point.

The issue comes in when they try to submit the entire form. The ajax validation is returning that the field is invalid (even though the inline validation returned good) and thus, they cannot submit the form.

I think I might have described it better in my first couple comments, but maybe this clarified a little.

As I mentioned, I debugged the JS in the browser and noticed that the loading message was triggering the form to be invalid.

Any ideas? Thanks for your help. This issue has really been a thorn in my side.

@posabsolute
Copy link
Owner

I will try to have a look on the weekend, pretty sure that has something to do with a patch a user submitted some times ago

@rjhilgefort
Copy link
Author

I appreciate it.

Also, thanks for the fantastic plugin.

@rjhilgefort
Copy link
Author

Any headway on this? Is there part of the setup that would be beneficial to see? Anything you want me to try?

@posabsolute
Copy link
Owner

Well I'm zeroing down bugs with ajax currently to make a new release, im on it, can you test the ajax php demo? see if you see the same behavior, I having a hard time figuring this one out

@jiribulan
Copy link

Hi, I have something similar, I am checking captcha code with ajax.

Everything is ok. The extra PHP script is run by validation engine, it receives all the values and returns JSON encoded array (I log it elsewhere). But it does not project into the validation field which still says "checking". It does not change even in ok or error message.

BTW I do not understand $validateError and $validateSuccess when you dont use it in the script anywhere.

@sas05
Copy link

sas05 commented Jan 22, 2013

Yes same things happened with me also.
here as well occurs same. what returns the value true or false, it says only *please wait loading....
http://www.position-relative.net/creation/formValidator/demos/demoAjaxInlinePHP.html

@bartclaeys
Copy link

Seems like this problem hasn't been fixed yet, even not in version 2.6.5, see:

#954

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants