I’ve got Ajax validation working great for forms, but I’d like the validation to kick on not only to handle the “change” event; I’d like the validation to also take place on for, e.g., the “keyup” event.
So in my view, I specify “Jevent” as an html option to, e.g., a textfield. When I did “view source” in my browser, I could see that Yii did indeed set the Jevent property of the text field properly. So far so good. Here’s a snippet of the view:
<div class="row">
<?php echo $form->labelEx($model,'author'); ?>
<?php
echo $form->textField($model,'author',
array('size'=>60, [b]'Jevent'=>'keyup change'[/b]));
?>
<?php echo $form->error($model,'author'); ?>
</div>
Amazingly enough, this worked the first time that I used it; but it FAILS on subsequent tries. Specifically, here’s the sequence:
[list=1]
[*]Load the page
[*]Place cursor in the author textbox
[*]Immediately leave the textbox – either by clicking elsewhere, or via TAB button
[*]Validation error shows, as it should
[*]Place cursor again into the author textbox
[*]Type any letter
[*]Validation error disappears–exactly the behavior I want.
[*]Now go on to populate other inputs on the form
[*]Re-enter the author textbox again, and cause the validation to appear, by leaving the field blank.
[*]Re-enter the author textbox one final time, and type in a letter.
This should cause the validation error to disappear, as it did before,
but this second time around, the validation error does not go away.
[/list]
Ideas, anybody? Why would Jquery pay attention to keyup events the first time, but not on subsequent tries?
Thanks!