javascript - Jquery validation remote not working -


i using violin validate if email or username unique remote option not working , have no clue why.

here js code

$('.form').validate({     rules: {         email: {             required: true,             email: true,             remote: {                 url: "../app/codecourse/validation/validator.php/",                 type: "post",                 data: {                     email: function() {                          return $( "#email" ).val();                     }                                        }             }         },         username: {             required: true,             rangelength: [6,16],             alpha: true,             remote: {                 url: "../app/codecourse/validation/validator.php/",                 type: "post",                 data: {                     username: function() {                         return $( "#username" ).val();                     }                 }             }         }, 

and here php validation class extends violin

class validator extends violin {      protected $user;     protected $hash;     protected $auth;      public function __construct(user $user, hash $hash, $auth = null) {         $this->user = $user;         $this->hash = $hash;         $this->auth = $auth;          $this->addfieldmessages([             'email' => [                 'uniqueemail' => 'that email in use.'             ],             'username' => [                 'uniqueusername' => 'that username in use.'             ]         ]);          $this->addrulemessages([             'matchescurrentpassword' => 'that not match current password'         ]);     }      public function validate_uniqueemail($value, $input, $args) {         $user = $this->user->where('email', $value);          if ($this->auth && $this->auth->email === $value) {             return true;         }          return ! (bool) $user->count();     }      public function validate_uniqueusername($value, $input, $args) {         return ! (bool) $this->user->where('username', $value)->count();     }      public function validate_matchescurrentpassword($value, $input, $args) {         if ($this->auth && $this->hash->passwordcheck($value, $this->auth->password)) {             return true;         }         return false;     } } 

i said in comments submit apparently can't submit form if not unique email or username

does have suggestion can me solve problem?

the response of validation call should either true valid form field, or error message invalid form fields. function validate_uniqueemail instance should return error message , not false


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -