dadamssg Posted July 5, 2009 Share Posted July 5, 2009 I have some text fields i want default values in but when the user click on i want them to be blank...." this.value='' " works but if the user clicks of to fix another text field, then clicks back on the other text field the value gets set back to being blank. anyone know how to make it to where it just goes blank ONCE to get rid of the default value? then the user can click off and back on again without losing his input? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/164875-solved-default-vaule-in-inputs-focus-to-blank-just-once/ Share on other sites More sharing options...
seventheyejosh Posted July 5, 2009 Share Posted July 5, 2009 onclick="if(this.value=='Default text string'){this.value=''};" Quote Link to comment https://forums.phpfreaks.com/topic/164875-solved-default-vaule-in-inputs-focus-to-blank-just-once/#findComment-869429 Share on other sites More sharing options...
Zane Posted July 5, 2009 Share Posted July 5, 2009 this would work better onclick="if(this.value==''){this.value='Default text string'};" I would also use onblur instead of onclick Quote Link to comment https://forums.phpfreaks.com/topic/164875-solved-default-vaule-in-inputs-focus-to-blank-just-once/#findComment-869432 Share on other sites More sharing options...
seventheyejosh Posted July 5, 2009 Share Posted July 5, 2009 but wouldnt that fill in the text? i think he wants it to start with a text, like have 'search' in the search input when the page loads. maybe: onfocus="if(this.value=='Default String'){this.value='';};" onblur="if(this.value==''){this.value='Default String';};" Quote Link to comment https://forums.phpfreaks.com/topic/164875-solved-default-vaule-in-inputs-focus-to-blank-just-once/#findComment-869437 Share on other sites More sharing options...
dadamssg Posted July 5, 2009 Author Share Posted July 5, 2009 that last one is perfect, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/164875-solved-default-vaule-in-inputs-focus-to-blank-just-once/#findComment-869441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.