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

Smarty Validate is number not complient with comma decimal

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


Joined: 08 Feb 2005
Posts: 4

PostPosted: Thu Feb 10, 2005 10:17 am    Post subject: Smarty Validate is number not complient with comma decimal Reply with quote

hi all,

i got a real small problem !
due to the affect that i am not aware of regex (what is really anoying) Sad

could anybody help me to hack isnumber of smarty validate to take comma as decimalpoint TOO?

the actual routine is

Code:
   
if(strlen($value) == 0)
    return $empty;       
return preg_match('!^\d+(\.\d+)?$!', $value);


how to get it working with decimal commans and points?

thx in advance chris
Back to top
View user's profile Send private message MSN Messenger
mohrt
Administrator


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

PostPosted: Thu Feb 10, 2005 2:33 pm    Post subject: Reply with quote

change \. to [\.,]

so the resulting change is:

return preg_match('!^\d+([\.,]\d+)?$!', $value);
Back to top
View user's profile Send private message Visit poster's website
eingfoan
Smarty n00b


Joined: 08 Feb 2005
Posts: 4

PostPosted: Thu Feb 10, 2005 4:04 pm    Post subject: Reply with quote

thanks very much !!!

btw do u know a good source for learning regex?

sincerely chris
Back to top
View user's profile Send private message MSN Messenger
mohrt
Administrator


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

PostPosted: Thu Feb 10, 2005 5:06 pm    Post subject: Reply with quote

Pick up Mastering Regular Expressions (Friedl) from O'Reilly, or google around for perl regular expression tutorials.
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Feb 10, 2005 5:24 pm    Post subject: Reply with quote

I raised my knowledge of regexs quite a lot just by reading the PHP manual. Still that experience paled next to reading Mastering Regular Expressions which is a rigorous and thorough examination of the topic. Unless regexs are somehow changed in a fundamental way, I'll never need another book on the subject. Highly Recommended.
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