I want to create a search field. My code so far:
<input type="text" value="Search" onfocus="if (this.value=='Search')
{this.value='';}" onblur="if (this.value=='') {this.value='Search';}"
class="textbox"/>
I want to change the <input> tag to @Html.Editor("term").
How can I write the onfocus and onblur events using @Html.Editor("term")?
Why not use HTML5
placeholderattribute it does the same thingReplace –
With
Demo: http://jsfiddle.net/uCkef/1/
Here is how you can make
'placeholder'attribute work in IE browsers –http://dipaksblogonline.blogspot.in/2012/02/html5-placeholder-in-ie7-and-ie8-fixed.html
And for focus and blur events –