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

problems w/ SmartyValidate and Regular expressions

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


Joined: 04 Jun 2004
Posts: 24

PostPosted: Wed Jul 14, 2004 3:15 am    Post subject: problems w/ SmartyValidate and Regular expressions Reply with quote

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
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Wed Jul 14, 2004 3:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Isidor128
Smarty Regular


Joined: 27 Jul 2004
Posts: 35
Location: France

PostPosted: Tue Jul 27, 2004 11:09 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
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