Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problem with latest version of smarty validate.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
robdawg
Smarty Rookie


Joined: 15 Jul 2005
Posts: 13

PostPosted: Wed Jul 20, 2005 7:03 pm    Post subject: Problem with latest version of smarty validate. Reply with quote

Here is my PHP Code:

Code:
if (empty($_POST)) {
   SmartyValidate::connect($smarty, true);
   SmartyValidate::register_form('Registration');
    SmartyValidate::register_validator('checkUsername1', 'username', 'notEmpty', false, false, 'trim', 'Registration');
    SmartyValidate::register_validator('checkUsername2', 'username:3:16', 'isLength', false, false, 'trim', 'Registration');
    SmartyValidate::register_validator('checkUsername3', 'username:/^([a-zA-Z0-9])*$/', 'isRegex', false, false, 'trim', 'Registration');
    SmartyValidate::register_validator('checkUsername4', 'username', 'isValidUsername', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword11', 'password1', 'notEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword12', 'password1:3:16', 'isLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword13', 'password1:/^([a-zA-Z0-9])*$/', 'isRegex', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword14', 'password1:password2', 'isEqual', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword21', 'password2', 'notEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword22', 'password2:3:16', 'isLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkPassword23', 'password2:/^([a-zA-Z0-9])*$/', 'isRegex', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail11', 'email1', 'notEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail12', 'email1', 'isEmail', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail13', 'email1', 'isValidEmail', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail14', 'email1', 'isValidEmailDomain', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail15', 'email1:email2', 'isEqual', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail21', 'email2', 'notEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail22', 'email2', 'isEmail', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail23', 'email2', 'isValidEmail', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkEmail24', 'email2', 'isValidEmailDomain', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkFirstName1', 'pixelAuctionsPlusCheck:firstName', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkFirstName2', 'pixelAuctionsPlusCheck:firstName:1:32', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkLastName1', 'pixelAuctionsPlusCheck:lastName', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkLastName2', 'pixelAuctionsPlusCheck:lastName:1:32', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkAddress11', 'pixelAuctionsPlusCheck:address1', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkAddress12', 'pixelAuctionsPlusCheck:address1:1:64', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkCity1', 'pixelAuctionsPlusCheck:city', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkCity2', 'pixelAuctionsPlusCheck:city:1:64', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkState1', 'pixelAuctionsPlusCheck:state', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkState2', 'pixelAuctionsPlusCheck:state:1:64', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkZipCode1', 'pixelAuctionsPlusCheck:zipCode', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkZipCode2', 'pixelAuctionsPlusCheck:zipCode:5:10', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkCountry1', 'pixelAuctionsPlusCheck:country', 'dependsOnEmpty', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkCountry2', 'pixelAuctionsPlusCheck:country:2:2', 'dependsOnLength', false, false, 'trim', 'Registration');
   SmartyValidate::register_validator('checkTermsOfService', 'termsOfService:1:1', 'isRange', false, false, 'trim', 'Registration');
    $smarty->assign('newForm',1);
} else {
   SmartyValidate::connect($smarty);
   SmartyValidate::register_object('registrationValidator',$registrationValidator);
   SmartyValidate::register_criteria('isValidUsername', 'registrationValidator->checkUsername', 'Registration');
   SmartyValidate::register_criteria('isValidEmail', 'registrationValidator->checkEmail', 'Registration');
   SmartyValidate::register_criteria('isValidEmailDomain', 'registrationValidator->checkEmailDomain', 'Registration');
    if(SmartyValidate::is_valid($_POST,'Registration')) {


I created 2 Function dependsOnEmpty and dependsOnLength.

I used both of those for 7 fields to collect user information.

However whenever i submit I blank form it only returns an error message on the first one. If i do input on the first one then it will error on the second one and so on.

Any help?
Back to top
View user's profile Send private message
robdawg
Smarty Rookie


Joined: 15 Jul 2005
Posts: 13

PostPosted: Wed Jul 20, 2005 8:34 pm    Post subject: Reply with quote

Nevermind I figured this one out.

When in the validation function, $params['field'] needs to be unique. So I switched how I setup my register_criteria.

BEFORE:
pixelAuctionsPlusCheck:firstName
pixelAuctionsPlusCheck:firstName:1:32

AFTER:
firstName:pixelAuctionsPlusCheck
firstName:pixelAuctionsPlusCheck:1:32
Back to top
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Thu Jul 21, 2005 6:29 am    Post subject: Reply with quote

Hi,

I think you can get better code, when you register some custom validators.

Bye,
Markus
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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