Back to myContactForm.com - Easy email form creation and processing for your web site
myContactForm.com - Help Forum Forum Index myContactForm.com - Help Forum
Have a question that you need answered about myContactForm.com? Post it on this message board but first search this forum and read out FAQ to ensure it has not already been answered. This is not a board to post links to your site! SPAM will be deleted!
 
   Search MessagesSearch Messages
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to auto clear default value once clicked

 
Post new topic   Reply to topic    myContactForm.com - Help Forum Forum Index -> Form Management
View previous topic :: View next topic  
Author Message
joycevdb



Joined: 06 Sep 2007
Posts: 2

PostPosted: Mon May 18, 2009 2:46 am    Post subject: How to auto clear default value once clicked Reply with quote

Hello

Is there a way to auto clear a default value once a user clicks inside a field? ?
Back to top
View user's profile
mycontac
Site Admin


Joined: 31 Dec 2003
Posts: 2860

PostPosted: Mon May 18, 2009 12:13 pm    Post subject: Re: How to auto clear default value once clicked Reply with quote

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
View user's profile
joycevdb



Joined: 06 Sep 2007
Posts: 2

PostPosted: Wed May 20, 2009 1:11 pm    Post subject: thank you Nick Reply with quote

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
View user's profile
mycontac
Site Admin


Joined: 31 Dec 2003
Posts: 2860

PostPosted: Fri May 22, 2009 2:12 pm    Post subject: Re: thank you Nick Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    myContactForm.com - Help Forum Forum Index -> Form Management All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.11 © 2001, 2002 phpBB Group