Posts

Showing posts from March, 2017

jQuery form validation (CUSTOM VALIDATION)

Code Structure :  $.validator.addMethod("field_name","function(value){}","Message"); jQuery Custom NID Validation :  $.validator.addMethod("nid_valid",function(value){    if(value.length == 10 || value.length == 13 || value.length == 17){       return true;    }else{       return false;    } },"NID number length 10, 13, 17 is valid");

LARAVEL CUSTOM VALIDATION

NID Validation :) 1> app/Providers/AppServiceProvider.php public function boot(){    $this->app['validator']->extend('nid',function($attribute,$value,$parameters){    $length = strlen($value);    if(in_array($length,[10,13,17])){        return true;    }else{        return false;    } }); } 2> resources/lang/en/validation.php return [    'nid' => 'The :attribute valid NID must be 10 | 13 | 17', ];