Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: smartyValidate

  1. #1
    Regular Coder
    Join Date
    Oct 2010
    Location
    Florence, MS
    Posts
    486
    Thanks
    10
    Thanked 33 Times in 32 Posts

    smartyValidate

    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:
    PHP 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'); 
    PHP Code:
    <form class="form" action="signup.php" method="POST">
        <
    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>
        <
    class="password">
            {
    validate id="pWord" message="Password cannot be empty"}
            <
    input type="password" name="password" id="password" />
            <
    label for="password">Password</label>
        </
    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>
        <
    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>
        <
    class="submit">
            <
    input type="submit" value="Sign Up" name="signup" />
        </
    p>
    </
    form
    Notice: If you post a problem and it gets fixed, please remember to go back and place it as solved. ;)
    I always recommend the HEAD First series of books for learning a new coding language. ^_^

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Try removing the apostrophes from the words 'true' and 'false'.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •