Revision #4 has been created by Kostas Apazidis (KonApaz) on Mar 5, 2014, 10:59:47 AM with the memo:
better approach
« previous (#3) next (#5) »
Changes
Title
unchanged
ClientValidation for files (modern browsers)
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
ClientValidation, file, before, uploading, model, browsers
Content
changed
[...]
add this
```php
$infoFieldFile = (end($form->attributes));
//or $infoFieldFileID = CHtml::activeId($model, 'file');
```
right below of the $form->error($model, 'file'....[...]
<script>
function customValidateFile(messages){
var nameC= '#<?php echo $infoFieldFile['inputID']; ?>';
//or var nameC= '#<?php echo $infoFieldFileID; ?>';
var control = $(nameC).get(0);
//simulates the required validator and allowEmpty setting of the file validator
if (control.files.length==0) {[...]