/ Published in: JavaScript
Often you supply a default value in a text field which you want to automatically clear when the user enters the field. This will do that operation and fill the field with a default value.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function no_empty(field, text) { if( field.value == "") { field.value = text; } } /* call with an onblur event * example: * <input type="text" maxlength="24" onblur="no_empty(this, \'City\')" id="city" name="city" * value="City" />' */