Link to home
Start Free TrialLog in
Avatar of HelpNearMe
HelpNearMeFlag for Afghanistan

asked on

HTML input text box onchange event

Hi Experts,

I'm no javascript expert so I need a hand with this.  See attached screenshot.

Currently the input field that has the text 'Full Name' is just a standard input text element with the value set to 'Full Name'.  This sucks because the user needs to delete the text in order to update the contents.

How can I use javascript to clear the value when the user clicks inside the input box?

Thanks,

HNM
sample2.jpg
SOLUTION
Avatar of Tony van Schaik
Tony van Schaik
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HelpNearMe

ASKER

I forgot to mention that it's a joomla 1.5 site, and I just tried your suggested code and it killed the image slider (JT Slideshow) which must use jquery too.  I even removed your call to the google CDN for 1.7.2 and it still killed the slideshow.. and in both instances focus event value update didn't work.

I should have mentioned the joomla thing first, but do you have any ideas how to do this given the new constraints?

HNM
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think you just need to add this code to your textbox html

 onclick="if(this.value=='Full Name') this.value=''"

Open in new window


With this code, when user clicks on the text box, default text 'Full Name' will be cleared.

You append to your html code like this

<input type="text" name="fname" value="Full Name" onclick="if(this.value=='Full Name') this.value=''">
I try some of the ideas tonight

thanks,

HNM
the external js file worked with the addition of $.noConflict
Thanks!

HNM