php - how to make an input date field greater than or equal to another date field using validation in laravel -
hi iam developing application using laravel there way make input date field greater or equal date field using validation.
i know can achieve through jquery , have got working, want know whether achievable through laravel validation since laravel has got predefined validations.
for example
protected $validationrules = array ( 'a' => 'date', 'b' => 'date|(some validation b value greater or equal of 'a')' );
edit
if there other approach solve problem using laravel concept please tell me
i tried
validator::extend('val_date', function ($attribute,$value,$parameters) { return preg_match("between [start date] , dateadd("d", 1, [end date])",$value); });
thanks in advance
i had same problem. before
, after
not work when dates same. here short solution:
// 5.1 or newer validator::extend('before_or_equal', function($attribute, $value, $parameters, $validator) { return strtotime($validator->getdata()[$parameters[0]]) >= strtotime($value); }); // 5.0 & 4.2 validator::extend('before_or_equal', function($attribute, $value, $parameters) { return strtotime(input::get($parameters[0])) >= strtotime($value); });
$rules = array( 'start'=>'required|date|before_or_equal:stop', 'stop'=>'required|date', );
edit: laravel 5.3.25 , later have new built in rules: before_or_equal
, after_or_equal
Comments
Post a Comment