|
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 |
hristov Smarty Rookie
Joined: 04 Jun 2004 Posts: 24
|
Posted: Wed Jul 14, 2004 3:15 am Post subject: problems w/ SmartyValidate and Regular expressions |
|
|
Code: |
{validate field="cst_SSN" criteria="isRegExp" expression="!^\d{6,10}$!" transform="trim" message="SSN/DLN may contain only 6-10 digits. " append='error_list'}
|
The problem is the second brace in the {6,10} <--
It may be smarty or smartyvalidate but it interprits ths brace as closing of the tag. is there any way I can escape this. I tried \{6,10\} but it did not help. Any suggestions.
is there any way to work around this, I don't want to have to check every file in my project for the existence of braces if I were to change smarty's opening and closing tags.
________
Expatriate insurance dicussion
Last edited by hristov on Sat Feb 12, 2011 7:44 pm; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jul 14, 2004 3:27 am Post subject: |
|
|
Use other criteria already available:
{validate field="foo" criteria="isInt" ... }
{validate field="foo" criteria="isLength" min=6 max=10 ... }
Or build your own plugin(s). Using regex in the template is generally a bad idea, I should have never put that plugin in the dist.
I suppose you could put the regexp in a variable too. |
|
Back to top |
|
Isidor128 Smarty Regular
Joined: 27 Jul 2004 Posts: 35 Location: France
|
Posted: Tue Jul 27, 2004 11:09 pm Post subject: |
|
|
mohrt wrote: | I suppose you could put the regexp in a variable too. |
That's workin fine
Code: |
$smarty->assign("regexpfam","/^([1-9][0-9]{1,2})(-[1-9][0-9]{1,2})*$/");
|
Code: |
<input type="text" name="Fam" value="{$Fam}" />
{validate field="Fam" criteria="isRegExp" expression=$regexpfam empty="yes" transform="trim" message="numerique"}
|
Thanks from this Post I've solved one of my issues |
|
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
|