robdawg Smarty Rookie
Joined: 15 Jul 2005 Posts: 13
|
Posted: Wed Jul 20, 2005 7:03 pm Post subject: Problem with latest version of smarty validate. |
|
|
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? |
|