Jump to content

on.click invisible?


cpugeek

Recommended Posts

Ok, I made a search and I was wondering is it possible to have a value filled in on the search but on.click it disappears so there is no value until you unclick?paraphrase: I want a value in a form and on.click I want it to disapear so the user can type ,but if no value is entered in on unclick then the value reverts to original-any help appreciated :)

Link to comment
Share on other sites

A better way might be to look at the onfocus and onblur events. You could use the onfocus event to check the value of the field to see if it is the default value that you specified. If it is, you could then clear it to make room for the user input. If it is not, you could ignore it so that it doesn't clear out what the user may have already written.You could then use the onblur event to check the value of the field to see that there is something written in it. If it is empty, you could insert your default text.

Link to comment
Share on other sites

This code is for textareas, but I think you can change it to whatever you like:

<TEXTAREA NAME="Textarea Name" ROWS="??" COLS="??" style="font-family: arial;" onfocus="if (this.value=='Your Message.') {this.value='';}" onblur="if (this.value=='') {this.value='Your Message.';}">Your Message.</TEXTAREA>
Just change the bits in bold, but make sure that you don't use an apposrophe '.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...