CActiveForm textField onfocus event


in my current project I hit on a problem in a ActiveForm.

Besides the default Validation of the textField I want to clear the value attribute of the input element when the user clicks into the input field and if the user clears the value of the input field and leaves the input field, the value of the previous input field should be set to the input field’s label.

I tried that with adding onfocus and onkeydown event by using $htmloptions but unfortunately the browser crashes when the events are fired.

Does someone have an idea how to solve this problem?


Hi, interestingly, I have the exact OPPOSITE issue. My textfield forms only behave the way you describe, and I actually want to reverse it. For example, if a user enters “john smith” into a textfield form and submits, then comes back to the form later, he cannot “clear” the field. It’s almost as if my delete button is deactivated. I can only enter another value, but cannot clear the field to zero. Any thoughts?