Jump to content

Recommended Posts

does PHP have a code to clear default values onlick??

 

For example if I have a text field...How do i insert blurry default value and when user click it the value will be gone if the user did not enter any value then the blurry default value would appear again??

 

Like on a sign up page...you want to let them know what is the format to by input into the fields.

 

<label for="telno">Contact No.: </label>
         <input type="text" name="telno" id="telno" class="regfields"/>

Link to comment
https://forums.phpfreaks.com/topic/260071-clear-default-value-using-php/
Share on other sites

html5 allows you to set a placeholder attribute, ie

 

<input type="text" name="date" value="" placeholder="mm/dd/YYYY">

 

Otherwise you have to use a little JS to do it, such as

 

<input type="text" name="date" value="mm/dd/YYYY" onfocus="if (this.value==this.defaultValue) this.value='';" onblur="if (this.value=='') this.value=this.defaultValue;">

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.