Erasing text in textarea

From FacileWiki

This is how to have the default text of a textarea to disappear when clicked on it...

On the textarea script area :

Action script --> custom

click on 'create code structure' and modify it to look as follow : (your function name will be different, based on your textarea name ...)

function ff_observations_action(element, action){
    switch (action) {
        case 'click': element.value='';
            break;
        default:;
    } // switch
} // ff_observations_action


The above function have 2 drawbacks :

- what has been written to answer will be deleted if you click on it again !

- if somebody click on it without meaning and don't type anything. He may not remember later what was written (case of long forms).


To enhance it, adding an unfocus(blur) testing is better :

    switch (action) {
        case 'click': if (element.value=='YourFieldValue'){element.value=''};
            break;
        case 'blur': if (element.value==''){element.value='YourFieldValue'};
            break;
        default:; 

also, make sure you check the 'blur' checkbox action in the triggering list of Action Script

| Terms of Use | Privacy | Sitemap |
Editing tools
Personal tools