Cdatevalidator Has Not Client-Javascript Validator

Hi my friends

I created a form with a lot of input type like integer, string, and date by specific format

I also make rules for those input (Model) and I enabled ‘enableClientValidation’ => true, on form (View) to check the user values before submits the form.

Everything is ok for integer, min max values etc by javascript except the date format javascript validator that in not exists!

I check on yii framework folder

The file like CNumberValidator.php implements clientValidateAttribute method

but I couldn’t found clientValidateAttribute method in CDateValidator.php file.

Whats wrong?


I guess it’s not implemented just because it is very cumbersome.

As you see in the source of it, CDateValidator.validateAttribute uses CDataTimeParser.parse to validate the attribute.

And CDateTimeParser.parse is quite a long and heavy method with a lot of branches.

I would never want to write the equivalent of it in javascript.

Hi softark

Thanks for the response

I know that but it would be useful

Anyway I change the rule type ‘date’ to ‘match’ , using another validator

I replace

'date', 'format'=>'d/M/yyyy'

with this one

'match', 'pattern'=>'#d{2}/\d{2}/\d{4}#'

Everything works ok :)

Ah, nice idea! :)