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

Validate form field only if its not empty

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


Joined: 04 May 2004
Posts: 10
Location: Stuttgart, Germany

PostPosted: Wed Jul 07, 2004 1:19 pm    Post subject: Validate form field only if its not empty Reply with quote

Hi guys,

I need some help with the SmartyValidator.
I am trying to validate a field only if it is not empty.
The Validation should be set to true if there is no content in the field, but if there is something typed in, I want to check for a number.

Example :

Leave the field empty : Form continues
Field has value "123" by the user : Form checks for isnumber.

Thanks in advance for your help!
_________________
See ya, Lemming
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Wed Jul 07, 2004 1:25 pm    Post subject: Reply with quote

{validate field="myfield" criteria="isNumber" empty=true message="..."}

That will allow a decimal value too, use isInt for whole numbers only.
Back to top
View user's profile Send private message Visit poster's website
einlemming
Smarty Rookie


Joined: 04 May 2004
Posts: 10
Location: Stuttgart, Germany

PostPosted: Wed Jul 14, 2004 1:15 pm    Post subject: Reply with quote

Thanks a lot for your help mohrt. This one worked for me Idea
_________________
See ya, Lemming
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