Skip to content

Ajax Validation of a field not returning the correct state in jqv.field.result #608

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

Closed
FHoulbreque opened this issue Feb 12, 2013 · 2 comments

Comments

@FHoulbreque
Copy link

Hello,

I am making a new website (sorry, it's in french) and trying to use the AJAX validation stuff.

If the message and form validating are working perfectly, sadly, the field AJAX validation return a false value. This is an issue as long as I bound jqv.field.result to change fields class.

// JavaScript Document
$(function() {
    $('#formLogin').validationEngine({
        autoPositionUpdate:     true
    });
    $('#formLogin').bind('jqv.field.result', function(e, field, errorFound, promptText) {
        if(errorFound) {
            field.parents('.control-group').removeClass('success').addClass('error');
        } else {
            field.parents('.control-group').removeClass('error').addClass('success');
        }
    });
    $('#formLogin button:reset').click(function(e) {
        $('#formLogin .control-group').removeClass('error success');
        $('#formLogin').validationEngine('hideAll');
    });
});

If this is working perfectly on the password field, but on the email one, it is returning an error.

Maybe it's working as intended as I read it's "undefined" and not false but, I can't find a way to check if the AJAX field validation is done. So either it's a feature request or a bug correction.

Thanks.

@FHoulbreque
Copy link
Author

After investigating a bit, I goes through the _ajax method a bit.

If I am right, on line 1387, it checks for the field being validated with other checkers and only proceed to the ajax request if all the previous checkings are done and the Ajax checks is not already done:

// If there is an error or if the the field is already validated, do not re-execute AJAX
if (!options.isError && !methods._checkAjaxFieldStatus(field.attr("id"), options)) {

Later, around line 1415, it checks for the ajax request status when the status is false and there is an error and set arcodingly the options.isError to true :

if (!status) {
     // Houston we got a problem - display an red prompt
     options.ajaxValidCache[errorFieldId] = false;
     options.isError = true;

So, why on line 1433, the options.isError is not set to false ? I tried and seems to solve my issue and many others as I looked backward into other issues:

 } else {
     options.ajaxValidCache[errorFieldId] = true;

I replaced this by:

 } else {
     options.ajaxValidCache[errorFieldId] = true;
     options.isError = false;

Sorry if I am posting the wrong way, I am new on GitHub and in web development. Trying to learn.

@posabsolute
Copy link
Owner

Hi I know that the ajax validation seems to be in problem for some time, I will have a look at your possible fix soon

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

3 participants