Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

SmartyValidate question.

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
newname
Smarty Rookie


Joined: 25 May 2008
Posts: 26

PostPosted: Wed Jul 09, 2008 7:24 pm    Post subject: SmartyValidate question. Reply with quote

how do we find which field is not valid?
like:

Name : ||||||||||||||||
Email: |||||||||||||||||
Password: ||||||||||||||

suppose email field sent out the error message.
and smarty printed it.
but how do we find that email field has given out the message..
for example:

<input name="email" type="text" {if $smarty.session.email.isnotvalid}class="error"{/if} value="" />

how do we do this?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7364
Location: Lincoln Nebraska, USA

PostPosted: Wed Jul 09, 2008 7:56 pm    Post subject: Reply with quote

You might do this:

Code:
{validate id="email" message="Email is not valid" assign="email_error"}
<input name="email" type="text" {if !empty($email_error)}class="error"{/if} value="" />
Back to top
View user's profile Send private message Visit poster's website
newname
Smarty Rookie


Joined: 25 May 2008
Posts: 26

PostPosted: Fri Jul 11, 2008 2:17 pm    Post subject: Reply with quote

nope it doesnt work.
BUt, it makes something else to not work
it doesnt show any kind of error message anymore !
my validator was working fine, gave me error message "Please enter your Full Name", but when I used assign="name_error", it isnt showing any error message now.
and my input field :
<td><input type="text" name="linkname" id="linkname"{if !empty($name_error)} class="error_field"{/if} value="{if isset($smarty.post.linkname)}{$linkname}{/if}" size="32" maxlength="45"></td>

doesnt show up class="name_error" in it..
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7364
Location: Lincoln Nebraska, USA

PostPosted: Fri Jul 11, 2008 3:29 pm    Post subject: Reply with quote

When you use assign="name_error", your message will be in {$name_error}, test and see if your error is there.
Back to top
View user's profile Send private message Visit poster's website
newname
Smarty Rookie


Joined: 25 May 2008
Posts: 26

PostPosted: Fri Jul 11, 2008 4:13 pm    Post subject: Reply with quote

yep, I knew that error can be called using {$name_error} , Its setting variable.. but the class="error_field" isnt showing up..the whole point of this thread was to show class="error_field" somehow..

Thank for help..
Back to top
View user's profile Send private message
newname
Smarty Rookie


Joined: 25 May 2008
Posts: 26

PostPosted: Fri Jul 11, 2008 4:16 pm    Post subject: Reply with quote

okay, thanks for help.. i sorted it out myself.. er.. I didnt actually.. it just sorted itself...anyway, thanks for help Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons All times are GMT
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 © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP