javascript - make the initial value of an input to disappear on click and to go back on blur -
i have form contains inputs initial value. want when click on input , click off default value go back. , if click on , type in, won't try erase put if go click on again.
this code tried :
<input type="text" name="prenom" value="prénom" onfocus="this.value = this.value=='prénom'?'':this.value;" onblur="this.value = this.value==''?'prénom':this.value;"/>
isn't there other method that, because code long.
if aren't worried older browsers, can use this:
<input type="text" name="prenom" placeholder="prénom"/>
Comments
Post a Comment