0

Using the Bootstrap validator remote, fields are validated successfully. How can you then have a conditional statement if valid is true to perform a certain action and if false then do something else. This is my validator:

 agentPwd:{
     validators :{
         remote : {
             url : '/agent',
                    data : function(validator) {
                    return {
                        agentPwd : validator.getFieldElements('agentPwd').val()
                            };
                    },
                    message : 'Invalid user and/or password',
                },
            }
        },

I want to know how can an if-else statement will fit into here, such as one below:

    if(valid === true){
        alert('success'),
    }else{
        alert('fail'),
    }
Sparky
  • 98,165
  • 25
  • 199
  • 285
user94628
  • 3,641
  • 17
  • 51
  • 88

1 Answers1

1

There are various events you can listen to, such as success.form.bv or error.form.bv.

plalx
  • 42,889
  • 6
  • 74
  • 90
  • Thanks .....so something like this should work in addition to the above code: $(document).ready(function() { $(form) .bootstrapValidator({ onError: function(e) { alert('fail'), }, onSuccess: function(e) { alert('success'), } }); }); – user94628 Nov 01 '14 at 12:26