formvalidation how to use remote only when needed

177 views Asked by At

i'm using this plugin to validate my form. in case of password i have two validations. one is regex and the other one is remote. the regex is inline.

username: {
    verbose: false,
        validators: {
            notEmpty: {
                message: 'Please enter a username.'
            },
             remote: {
                 type: 'POST',
                    url: 'validator.php',
                    message: 'That username is already taken.',
                    delay: 500
             }
          }
     }

if the entered username doesn't follow the regex rule, i don't want the remote to check for exist username. right now if the user entered 'abc' for username i'm getting the regex error and one second later i get 'That username is already taken'. i want to show only one message and on this case the regex error should appear.

i tried using callback but i don't know how to continue from there.

0

There are 0 answers