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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -