|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
newname Smarty Rookie
Joined: 25 May 2008 Posts: 26
|
Posted: Wed Jul 09, 2008 7:24 pm Post subject: SmartyValidate question. |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jul 09, 2008 7:56 pm Post subject: |
|
|
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 |
|
newname Smarty Rookie
Joined: 25 May 2008 Posts: 26
|
Posted: Fri Jul 11, 2008 2:17 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Jul 11, 2008 3:29 pm Post subject: |
|
|
When you use assign="name_error", your message will be in {$name_error}, test and see if your error is there. |
|
Back to top |
|
newname Smarty Rookie
Joined: 25 May 2008 Posts: 26
|
Posted: Fri Jul 11, 2008 4:13 pm Post subject: |
|
|
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 |
|
newname Smarty Rookie
Joined: 25 May 2008 Posts: 26
|
Posted: Fri Jul 11, 2008 4:16 pm Post subject: |
|
|
okay, thanks for help.. i sorted it out myself.. er.. I didnt actually.. it just sorted itself...anyway, thanks for help |
|
Back to top |
|
|
|
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
|