css - HTML textarea tag help required -
i have set default value in textarea. want when clicks on textarea default value disappears. whats html code that?
<textarea onfocus="this.value = ''">this default value</textarea>
this little piece of code responsible:
onfocus="this.value = ''"
basically when focus event fired, value of current field set empty string ""
of course can make more complexe , make sure erase when element contains default message:
<textarea id="myfield">this default value</textarea>
javascript:
var defaultmsg = "this default value"; document.getelementbyid("myfield").onfocus = function () { if (this.value == defaultmsg) { this.value = ""; } } document.getelementbyid("myfield").onblur = function () { if (this.value == "") { this.value = defaultmsg; } }
Comments
Post a Comment