valiantshady Posted March 29, 2012 Share Posted March 29, 2012 Greetings,Hey everyone, I've had a query about how to create a form text box with some value inside that gets automatically cleared as the user clicks on it to edit it, more like this example on www.bodybuilding.com they have a sign in form at the right hand-side next to the flash slide show.. Sorry if my question is not that professional but I can't seem to know how from their source code.. Thanks for your time and effort.. Link to comment Share on other sites More sharing options...
eTianbun Posted March 29, 2012 Share Posted March 29, 2012 In the <input> onfocus attribute, you use javascript pass a command to the browser to empty the input, when user click (focus) on it with a mouse and the default value is there.EX: <input type="text" value="Enter name" onfocus="if(this.value=='Enter name'){this.value=''}"> Link to comment Share on other sites More sharing options...
dsonesuk Posted March 29, 2012 Share Posted March 29, 2012 <input type="text" value="Enter name" onfocus="if(this.value==this.defaultValue){this.value=''}" onblur="if(this.value==''){this.value=this.defaultValue}"> Link to comment Share on other sites More sharing options...
valiantshady Posted March 29, 2012 Author Share Posted March 29, 2012 Oh my god, eTianbun and dsonesuk you're the best, I really didn't have any idea how to do that..Thanks a lot my friends i am really thankful! :Happy: Link to comment Share on other sites More sharing options...
TheGallery Posted March 29, 2012 Share Posted March 29, 2012 You could also use http://www.w3schools.com/html5/att_input_placeholder.asp although it's not supported by all browsers (i think) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.