/ Published in: JavaScript
                    
                                        Clear a field on entry if the default text matches a supplied value. Generic to any field.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 function activate_field(field,txt) { if (field.value === txt) { field.value = ""; } else { $(field).select(); } } /* * call with an onfocus event * example: * <input type="text" onfocus="activate_field(this,\'City\')" * id="city" name="city" value="City" />' */
Comments
                    Subscribe to comments
                
                