View previous topic :: View next topic |
Author |
Message |
joycevdb
Joined: 06 Sep 2007 Posts: 2
|
Posted: Mon May 18, 2009 2:46 am Post subject: How to auto clear default value once clicked |
|
|
Hello
Is there a way to auto clear a default value once a user clicks inside a field? ? |
|
Back to top |
|
 |
mycontac Site Admin
Joined: 31 Dec 2003 Posts: 2860
|
Posted: Mon May 18, 2009 12:13 pm Post subject: Re: How to auto clear default value once clicked |
|
|
joycevdb wrote: |
Hello
Is there a way to auto clear a default value once a user clicks inside a field? ? |
This can be done by adding some additional javascript to the text field once you've pasted to the site.
If you look at the HTML code for the text field, it should look similar to this:
Code: |
<input name="q[some_number]" type="text" id="q[some_number]" value="Predefined Answer Text" size="Some Number" maxlength="Some Number" /> |
You can enter a bit of javascript into this text box so that the web browser will clear it when clicked.
Code: |
onclick="this.value = '';" |
Insert the above code into the text field so the entire thing should look something like this:
Code: |
<input name="q[some_number]" type="text" id="q[some_number]" value="Predefined Answer Text" size="Some Number" maxlength="Some Number" onclick="this.value = '';" /> |
This should do the trick.
Nick Ladd
myContactForm.com |
|
Back to top |
|
 |
joycevdb
Joined: 06 Sep 2007 Posts: 2
|
Posted: Wed May 20, 2009 1:11 pm Post subject: thank you Nick |
|
|
thank you Nick!
I appreciate your quick response. My contact email was incorrect in my contact info (obviously my fault)-- so I didn't know that this was answered.
I got it to work like this -- maybe this is over doing it....looks very close to your code. This definitely works and returns the correct fields. Do you see any issues / conflicts with this?
<input name="q[4]" onfocus="if(this.value=='Company') this.value='';" onblur="if(this.value=='') this.value='Company';" value="Company" size="20" alt="Company" type="text" />
Thanks again! |
|
Back to top |
|
 |
mycontac Site Admin
Joined: 31 Dec 2003 Posts: 2860
|
Posted: Fri May 22, 2009 2:12 pm Post subject: Re: thank you Nick |
|
|
joycevdb wrote: |
thank you Nick!
I appreciate your quick response. My contact email was incorrect in my contact info (obviously my fault)-- so I didn't know that this was answered.
I got it to work like this -- maybe this is over doing it....looks very close to your code. This definitely works and returns the correct fields. Do you see any issues / conflicts with this?
<input name="q[4]" onfocus="if(this.value=='Company') this.value='';" onblur="if(this.value=='') this.value='Company';" value="Company" size="20" alt="Company" type="text" />
Thanks again! |
That looks like it should do the trick. I would test it yourself in a web browser to ensure it works.
Nick Ladd
myContactForm.com |
|
Back to top |
|
 |
|