I have a form that includes a deadline, and the user must set a deadline in the four input fields as follows:
<div class="form-group col-lg-3"> {!! Form::label('year', 'Year', ['class' => 'control-label']) !!} {!! Form::selectYear('year',$year, $year +1, null , ['class' => 'form-control']) !!} </div> <div class="form-group col-lg-3"> {!! Form::label('month', 'Month', ['class' => 'control-label']) !!} {!! Form::selectRange('month', 1, 12 , null , ['class' => 'form-control']) !!} </div> <div class=" form-group col-lg-3"> {!! Form::label('day', 'Day', ['class' => 'control-label']) !!} {!! Form::selectRange('day', 1, 31 , null , ['class' => 'form-control']) !!} </div> <div class=" form-group col-lg-3"> {!! Form::label('hour', 'Hour', ['class' => 'control-label']) !!} {!! Form::selectRange('hour', 6, 23 , null , ['class' => 'form-control']) !!} </div>
In formRequest, I collect these four fields as a deadline. So my formRequest looks like this:
public function rules() { $this->prepInput(); return [ ]; } public function prepInput(){ $input=$this->all(); ... $input['deadline']=$this->prepDeadline($input['hour'], $input['month'], $input['day'], $input['year']); ... $this->replace($input); } public function prepDeadline($hour,$month,$day, $year){ $time = jDateTime::mktime($hour, 0, 0, $month, $day, $year); return $deadline = strftime("%Y-%m-%d %H:%M:%S", $time); }
The deadline is the Jalali datetime, and I need to check if the user has selected a valid date or not (e.g. 1394/12/31 is not a valid date). The jDatetime package has a checkdate method that works just like php checkdate . Where and how can I confirm the date in thisRequest form and notify the user of the choice of a valid date? Actually, I need this check to be done before the deadline is passed to prepInput .