I wrote this little script to just create some self clearing input fields. Its pretty simple but it does the job.
Updated: A new version of this script can be found on my GitHub Account… its much sleeker and requires nothing to be put on the input fields.
First you have the js
//This can go in the main js or whatever...
function clearInput(staticValue, id){
if($(id).value == staticValue){
$(id).value = '';
$(id).observe('blur', function(){
if($(id).value == ''){
$(id).value = staticValue;
}
});
}
}
Just make sure you download and include prototype.
Here is a sample of the html!
Each Input field must have a unique ID for this to work. The first argument in the clearInput() function is the static value of the input field.
This entry was posted
on 04.29.2010 at 4:59 pm
and is filed under Code Bin.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.