How to display form values after entry when form name is in the field already

#1
[eluser]mact1079[/eluser]
I'd like to be able to display a user's input in an email field instead of wiping it out if form validation fails. If I don't have the field name in the field and were using labels I'd simply make 'value'=>set_value('email') however as you see below I have an onfocus and onblur call as this is a mobile form and I don't want to take up the screen space for labels.

Any ideas on how to retain the user's input with a modification to my code below if form validation fails, while initially having the field name in the field?

Code:
$useremail = array('name'=>'email', 'type'=>'email', 'value'=>'Email Address', 'onfocus'=>"if (value='Email Address') {value=''}",'onblur'=>"if (value=='') {value='Email Address'}");

#2
[eluser]CroNiX[/eluser]
Use the 2nd parameter of set_value()
Code:
'value'=> set_value('email', 'Email Address')

Value will initially be 'Email Address' unless form was submitted, then it will be the submitted value


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.