Jump to content

clear default value using php


hubertj

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;">

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.