...

View Full Version : smartyValidate



Chris Hick
07-29-2012, 07:00 AM
Okay, so I have started using the smarty validate class for validating forms for a website that uses the smarty template engine. It says on the smarty validate page that one can use multiple validations for a single field. But I have tried this but to know avail. Has anyone else come across this?? Any solutions??

Here is two snippets of my code:


SmartyValidate::register_validator('userEmpty','username','notEmpty','false','false','trim');
SmartyValidate::register_validator('userLength','username:6:32','isRange','false','false','trim');
SmartyValidate::register_validator('pWord','password','notEmpty','false','false','trim');
SmartyValidate::register_validator('pWord2','password2','notEmpty','false','false','trim');
SmartyValidate::register_validator('pWordEqual','password:password2','isEqual','false','false','trim ');
SmartyValidate::register_validator('emailEmpty','email','notEmpty','false','false','trim');
SmartyValidate::register_validator('emailValid','email','isEmail','false','false','trim');




<form class="form" action="signup.php" method="POST">
<p class="username">
{validate id="userEmpty" message="Username cannot be empty"}
{validate id="userLength" message="Username must be a minimum of 6 characters and a max of 32 characters."}
<input type="text" name="username" id="username" />
<label for="username">Username</label>
</p>
<p class="password">
{validate id="pWord" message="Password cannot be empty"}
<input type="password" name="password" id="password" />
<label for="password">Password</label>
</p>
<p class="password">
{validate id="pWord2" message="Password cannot be empty"}
{validate id="pWordEqual" message="Both password fields must be equal."};
<input type="password" name="password2" id="password2" />
<label for="password2">Password(Retype)</label>
</p>
<p class="email">
<p>
{validate id="emailEmpty" message="Email cannot be empty"}
{validate id="emailEmpty" message="Please enter a valid email"}
</p>
<input type="text" name="email" id="email" />
<label for="email">E-mail</label>
</p>
<p class="submit">
<input type="submit" value="Sign Up" name="signup" />
</p>
</form>

AndrewGSW
07-29-2012, 08:36 PM
Try removing the apostrophes from the words 'true' and 'false'.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum