Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > SmartyValidate: Error is reported when there is no error

SmartyValidate: Error is reported when there is no error
Thread Tools
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Nov 21, 2005, 12:59 AM
 
PHP file:
Code:
SmartyValidate::register_validator('pass1_len','password1:4:16','isLength',false,false,'trim'); SmartyValidate::register_validator('pass_equ','password1:password2','isEqual',false,false,'trim');
Template:
Code:
{validate id="pass1_len" message="Password must be between 4 and 16 characters."} {validate id="pass_equ" message="Passwords do not match."}
The problem is that if the first check fails, the second check triggers an error, *even* if they really are equal, but just under 4 characters in length. I can't use halt, because I have other validators that need to print after it, regardless. If I enter 4 characters into both fields, the equal error disappears.

My question is why does a validator trigger an error if it's a second validator and correct? I tried this with other validator criteria, and even my own criteria, and it always does the same thing. How do I get around it without halt? I shouldn't even have to use halt, because the error shouldn't have been triggered.

Also, if I submit a page with no data, both errors are shown. then i enter a valid pass in, both errors disappear, and if i delete the passwords and submit again, it works properly - only the password length error is shown.

With Smarty debugging on, it shows the right errors. It doesn't show the errors that shouldn't be shown, but are anyways:

Code:
{$desiredusername} empty {$emailaddress} empty {$errors} Array (5) desiredusername => Username must be between 2 and 16 cha... password1 => Password must be between 4 and 16 cha... firstname => First name must be between 2 and 16 c... lastname => Last name must be between 2 and 16 ch... emailaddress => Not a valid email address. {$firstname} empty {$lastname} empty {$password1} empty {$password2} empty
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Nov 21, 2005, 04:32 PM
 
I haven't seen those for Smarty before - are they add-ons you found somewhere?

From personal experience, I find it extremely reliable to use the PEAR QuickForm libraries to generate and validate forms, then use the Smarty Renderer to pass an array of data for Smarty to simply display, rather than parse.

http://pear.php.net/
Computer thez nohhh...
     
timmerk  (op)
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Nov 21, 2005, 06:44 PM
 
No, isLength, and isEqual come with SmartyValidate.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:43 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2