HTML5 placeholder attribute for IE9 and prior

One of the many nice features introduced in HTML5 is placeholder attribute for form fields, which is very useful to show helpful hints for the field. This can be done with JavaScript but it’s even better being native to HTML5. That is, until you use browser that doesn’t support HTML5, like IE9 (and before). There are…

Continue Reading »

Yii: AJAX validation and Duplicated data

When creating a new record, I noticed the new record is duplicated (usually 3x but sometimes 4x, 5x…) It took me a while to realize this is caused by AJAX validation. There are 2 things needed to be done from the code generated by Gii, if you want AJAX validation.

xajax: Append form fields and Firefox

A case that works in IE but not Firefox (for a change). Supposed there’s form with a few fields. A button to manually adding more fields to the form. These fields are grouped under the same <div> tag. When the fields are added to the form, the original field values are reset.

xajax and radio buttons

to display a group of choices to select-only-one as radio buttons, the name and id parameters must be the same for all <input> tags: to pass the value of radio button to xajax function, use this.value. not this.checked, as the value is always true when it’s clicked.

xajax and Checkbox

In one of the forms I work on, I need to set other form fields based on the value of a checkbox. The value this.checked was passed as  parameter to xajax function. In xajax function, the value of the parameter is either true or empty value. The problem is, the value in field1 always display…

Continue Reading »