I have the following code:
@Html.TextBoxFor(x => x.Name, new { @onload = "if(this.value=='')this.value='NAME';", @class = "text", @onblur = "if(this.value=='')this.value='NAME';", @onfocus = "if(this.value=='NAME')this.value='';" })
@Html.TextBoxFor(x => x.Email, new { @onload = "if(this.value=='')this.value='EMAIL ADDRESS';", @class = "text", @onblur = "if(this.value=='')this.value='EMAIL ADDRESS';", @onfocus = "if(this.value=='EMAIL ADDRESS')this.value='';" })
But it only says ‘NAME’ when the box is clicked on, I want it to be there to begin with.
Why not just use the HTML5 placeholder attribute? That seems to be what you’re trying to do.