Toggle default value of Text box

Saratvaddilli
Posted by Saratvaddilli under JavaScript category on | Points: 40 | Views : 1863
                    var t = document.getElementById('ID');
t.onfocus = hideText;
t.onblur = showText;

function hideText() {
if(this.value == this.defaultValue) {
this.value = '';
}
}

function showText() {
if(this.value == '') {
this.value = this.defaultValue;
}
}

Comments or Responses

Login to post response