/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// form input prefill clear on focus, and reset on blur (if empty) function prefillClear(field) { if (field.defaultValue==field.value) {field.value = '';} else if (field.value == '') {field.value = field.defaultValue;} } // usage <input type="text" name="input1" value="Enter your data" onfocus="prefillClear(this);" onblur="prefillClear(this);" /> // suggest using some further javascript to parse all input fields and apply these functions on domReady. This would save having to put the function calls inline.
Comments
