|
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 |
Dieter Smarty Rookie
Joined: 08 Sep 2003 Posts: 9
|
Posted: Thu Jul 29, 2004 2:23 pm Post subject: validate multiple fields |
|
|
I'm trying to build some forms for my website and I'm using SmartyValidate but I've come across some problems:
I have a few fields that should be INTs, but at least 1 of these fields should be > 0.
Code: |
{validate field="f1" criteria="isInt" transform="trim" message="##NG_OK##"}
<li><input type="text" name="f1" value="{$f1}"><br />
{validate field="f2" criteria="isInt" transform="trim" message="##NG_OK##"}
<li><input type="text" name="f2" value="{$f2}"><br />
{validate field="f3" criteria="isInt" transform="trim" message="##NG_OK##"}
<li><input type="text" name="f3" value="{$f3}"><br />
|
I should have a general {validate field="f1 OR f2 OR f2 criteria="not0"} on top of this but I don't think this is possible?
I hope that someone can help me out. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jul 29, 2004 2:36 pm Post subject: |
|
|
There isn't an easy way to do this yet. You could create a custom criteria for it:
{validate field="f1,f2,f3" critieria="oneIsGtZero" message="..."} |
|
Back to top |
|
Dieter Smarty Rookie
Joined: 08 Sep 2003 Posts: 9
|
Posted: Thu Jul 29, 2004 2:51 pm Post subject: |
|
|
mohrt wrote: | There isn't an easy way to do this yet. You could create a custom criteria for it:
{validate field="f1,f2,f3" critieria="oneIsGtZero" message="..."} |
I figured that out, but how can you validate multiple fields with one {validate} -tag? Separating them with ", " doesn't seem to work... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jul 29, 2004 2:56 pm Post subject: |
|
|
Your validation logic would need to split the values by commas and test each them. None of the criteria bundled with SmartyValidate work this way. |
|
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
|