When i add in the “name” field within cjuidatepicker, the client validation for the end_date does not work as specified in the model and I don’t know why. Below are my codes and the problem areas are commented in the codes.
Is there anything wrong or anyway I can allow validation to be done at the client side?
cjuidatepicker for start_date:
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model,
'attribute'=>'start_date',
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'dd-mm-yy',
'minDate' => '0',
'onSelect'=> 'js:function( selectedDate ) {
$( "#endDate" ).datepicker("option", "minDate", selectedDate); //set the end date cjuidatepiker minDate and its working fine
}',
),
'htmlOptions'=>array(
'style'=>'width:105px;vertical-align:top;font-size:0.9em;'
),
));
cjuidatepicker for end_date:
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'endDate', //Problem area:added in name so that in start date cjuidatepicker, I can assign the minDate of endDate, however I cannot do the client validation of a "required" field as specified within the rules of the model.
'model'=>$model,
'attribute'=>'end_date',
'options'=>array(
'showAnim'=>'fold',
'dateFormat'=>'dd-mm-yy',
'onSelect'=> 'js:function( selectedDate ) {
$("#eDate").val(selectedDate);
}',
),
'htmlOptions'=>array(
'style'=>'width:105px;vertical-align:top;font-size:0.9em;'
),
));
Display error Message of end date cjuidatepicker using client validation:
echo $form->error($model,'end_date'); //however this error message does not show even when the end_date cjuidatepicker has no values selected
Model rules of end date:
public function rules()
{
return array(
array('start_date, end_date', 'required'),
);
}