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

$.post() / re-validation after error #721

Open
gh59291 opened this issue Oct 8, 2018 · 0 comments
Open

$.post() / re-validation after error #721

gh59291 opened this issue Oct 8, 2018 · 0 comments

Comments

@gh59291
Copy link

gh59291 commented Oct 8, 2018

  1. useful & powerful library, thx 4 work.

i) i want to check age range from server with $.post action.

ii) Problem :
a) if first test is false -wrong date
b) and second test is good,
c) validator does not reset / perfome test and let form submit

In facts it seems that validation is not processed anymore.
Should i reset form validation before ?

iii) addValidator(s) :

-this works fine-

$.formUtils.addValidator({
    name : 'checkDateBirthHolderJs',
    validatorFunction : function(value, $el, config, language, $form) {
        var age=ageGet(value,'/'); console.log('checkDateBirthHolder='+age);
        var check=true;
        if(parseInt(age)<16){ check=false };
        if(parseInt(age)>45){ check=false };
        return check;
    },
    errorMessage : gloss.badBirthHolder,
    errorMessageKey: 'badBirthHolder'
});

this returns good ajax response but no "re-validation"

$.formUtils.addValidator({
    name : 'checkDateBirthHolderAjax',
    validatorFunction : function(value, $el, config, language, $form) {
        var csrf=$form.find('#csrf').val();
        var check=false;

        $.post( "/myController/dataCheck/", { csrf:csrf, date_birth:value, ac:'date_birth_holder', i18n:app.i18n }, function(rsp,status) { //console.log(rsp);
            var data = $.parseJSON(rsp); console.log(data); console.log(check);
            check=data.valid; console.log(check); //check ok
            return check;
        });

        return check;
    },
    errorMessage : gloss.badBirthHolder,
    errorMessageKey: 'badBirthHolder'
});

iv) using server leads to same problem.

What's wrong ?
Thx for tips & time
gh59291

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