What is the code to basically delete text within an input field when a mouse cursor is clicked within the field such as a input type text. Thanks a bunch!
| SitePoint Sponsor |
What is the code to basically delete text within an input field when a mouse cursor is clicked within the field such as a input type text. Thanks a bunch!





Show us what you have so far and lets take it from there.
I have no clue where to start, I assume it would be an OnClick function, but I don't know. Newb here





This is a perfect opportunity for you to learn JavaScript. Spend some time learning it! Fun huh?
![]()


Code:<form> <input type="text" name="txt1" value ="my text value" onfocus="if(this.value==defaultValue){ this.value ='';} ";> <input type="text" name="txt1" value ="my text value" onfocus="this.value='' ";> </form>





Or use onclick instead of onfocus.
Bookmarks