I have a Yii2 active form which includes a field with datepicker. My form is using following attributes:
<?php $form = ActiveForm::begin([
'id' => 'campaign-form',
'enableClientValidation' => true,
'fieldConfig' => [
'options' => ['class' => 'gg-create-group'],
'labelOptions' => ['class' => null],
],
'options' => [
'autocomplete' => 'off',
'enctype' => 'multipart/form-data',
],
]);
?>
I have a field using jquery datepicker, the issue is each time I click on the arrows to navigate through the months in the calendar, client validation is triggered an a error is shown:
I need to stop the error message if the calendar is open and I am using the calendar navigation.
I know I can turn off client validation using:
enableClientValidation => false
But I want to keep client validation. I am wondering if Yii javascript script: $yiiform has an option to do that?
I found a solution. I can use validationOnBlur, if I set it to false on specific field it fixes the issue.
<?php echo $form->field($model, 'client_end_date',
['validateOnBlur' => false])->textInput(['readonly' => 'readonly']); ?>