Page is a not externally linkable
- Code, Content, and Presentation
-- HTML
---- Change data in field after submit?


BradleyD - 12:47 am on Aug 26, 2012 (gmt 0)


Hi all!

I have a simple problem (I hope).

I wanted the text fields full instead of extra text on the page,
so I'm using the "onfocus" and "onblur" events in a form.
ie:
value='Enter Your First Name Here'

onfocus="this.value=''"

onblur="if(this.value=='')this.value=this.defaultValue;"

The problem is, if they don't enter any information,
the script captures the value data instead.

Here's the complete form:
*******************PASTE********************

<form method='POST' action='http://www.MYWEBSITE.com/cgi-bin/arp3/arp3-formcapture.pl'>
<div align='center'><center>
<p>Step 1:<br><input type='text' name='first_name' size='30'value='Enter Your First Name Here'

onfocus="this.value=''"

onblur="if(this.value=='')this.value=this.defaultValue;"></p>
</center></div>
<input type='hidden' name='capitals' value='1'>
<div align='center'><center>
<p>Step 2:<br><input type='text' name='email' size='30'value='Enter Your Email Here'

onfocus="this.value=''"

onblur="if(this.value=='')this.value=this.defaultValue;"></p>
</center></div>

<div align='center'><center>
<p>Step 3:<br><input type='text' name='custom_petname' size='30'value='Enter Your Pets Name'

onfocus="this.value=''"

onblur="if(this.value=='')this.value=this.defaultValue;"></p>
</center></div>

<input type='hidden' name='subscription_type' value=''><div align='center'><center>
<p><input type='image' SRC="images/Green%2001-Get%20It%20Now%20Big.png" style=
"BORDER-BOTTOM: black solid; BORDER-LEFT: black solid; WIDTH: 160px; HEIGHT: 36px; BORDER-TOP: black solid; BORDER-RIGHT: black solid"
border="0"
align="center"></p>
</center></div>
<input type='hidden' name='id' value='2'>
<input type='hidden' name='extra_ar' value=''>
<input type='hidden' name='first_name_man' value='1'>
</form>

*******************END PASTE********************

The form captures "Enter Your Pets Name" as the pet's name.
I wouldn't mind if the captured data was blank, but this is a problem.

I know I can leave the field blank if they click the field, using "onfocus=null",
but if they don't even click the field, the text doesn't clear.

Ultimately, if they don't enter anything,
I would like to send "your pet" to the string.

Any help would be great, this is just a bit beyond me.
And thanks for your time everyone!
You got a great place here :)
Brad.


Thread source:: http://www.webmasterworld.com/html/4488357.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com