pc131
(Skoczy)
1
How/where could I add some javascript code, to check if file was selected in standard file selection dialog? I would like to put some alert then.
I need this validation on update action.
The "_form.php" from "candidate" view has the file input field:
<div class="row">
<?php echo $form->labelEx($model,'cv'); ?>
<?php echo $form->fileField($model,'cv'); ?>
<?php echo $form->error($model,'cv'); ?>
</div>
How to check with javascript if file was selected on above field?
Thanks
you can check field value on ‘change’ event:
$('#your-file-field-id').on('change', function() {console.log(this.value);});
pc131
(Skoczy)
3
Hi ORey
where to put this code, and what is actually my "your-file-field-id", looking on the code
<div class="row">
<?php echo $form->labelEx($model,'cv'); ?>
<?php echo $form->fileField($model,'cv'); ?>
<?php echo $form->error($model,'cv'); ?>
</div>
can’t see the id…
You can put it in document.ready() section. Use registerJs for this.
Wow, people are getting helpless.
-
You can view the source of the page (i mean, HTML source)
-
You can use ‘inspect element’ of firebug or chrome dev console
-
You can see how activeForm’s fields are rendered
I believe it would be something like ‘YourModelName_cv’.