Welcome Guest, Not a member yet? Register   Sign In
reCAPTCHA 2 | Form Validation Rules
#1

[eluser]Dr. Seuss[/eluser]
Greetings.

Using reCAPTCHA 2 and I have the "basic" code working great. My question is: How do I add additonal form validation rules to the "rules" array that is in the reCAPTCHA 2 sample code?

My code--which doe not work--looks like:

Code:
$rules = array(                    
                       array(
                             "field" => "recaptcha_challenge_field",
                             "label" => "reCAPTCHA Label",
                             "rules" => "required|recaptcha_matches"
                             )
                       );
                      
    

    $rules['username'] = "trim|required|min_length[5]|max_length[50]|xss_clean";
    $rules['pwd'] = "trim|required|matches[confpwd]";
    $rules['confpwd'] = "trim|required";
    $rules['email'] = "trim|required|valid_email";
        
        $this->form_validation->set_rules($rules);
        // Do validation run
        if ($this->form_validation->run() == FALSE)

The additional fields that I am trying to add rules for is obviously in the section:

Code:
$rules['username'] = "trim|required|min_length[5]|max_length[50]|xss_clean";
    $rules['pwd'] = "trim|required|matches[confpwd]";
    $rules['confpwd'] = "trim|required";
    $rules['email'] = "trim|required|valid_email";

...but that does not work--the form validates even when I submit with these fields totally empty.

The form code looks like this:
Code:
<b>Create Account </b>

&lt;form action="../../auth" method="post"&gt;

<table>
    <tr>
        <td>User Name:</td>
        <td>&lt;input size=100&gt;&lt;/td>
    </tr>
    <tr>
        <td>Email:</td>
        <td>&lt;input size=100&gt;&lt;/td>

    </tr>
    <tr>
        <td>Password:</td>
        <td>&lt;input size=50&gt;&lt;/td>
    </tr>
    <tr>
        <td>Verify Password:</td>
        <td>&lt;input size=15&gt;&lt;/td>

    </tr>
    <tr>
        <td colspan=2 align='center'>[removed][removed]

    <noscript>
          &lt;iframe src="http://api.recaptcha.net/noscript?k=###################################" height="300" width="500" frameborder="0"&gt;&lt;/iframe><br/>
          &lt;textarea name="recaptcha_challenge_field" rows="3" cols="40"&gt;&lt;/textarea>
          &lt;input type="hidden" name="recaptcha_response_field" value="manual_challenge"/&gt;
    </noscript></td>
        <td></td>
    </tr>
    <tr>

        <td colspan=2 align='center'>&lt;input type="submit" value="Go" /&gt;&lt;/td>
        <td></td>
    </tr>
</table>
&lt;/form&gt;

This is my first go with the form validation class, so I am new to each stitch and if I am doing something stupid, I apologize in advance.
#2

[eluser]Dr. Seuss[/eluser]
Whoops. Close this thread.

"$this->form_validation->run()" is a reCAPTCHA 2 method, not the CI form validation method. Sorry. Thought it was all be handled by CI.




Theme © iAndrew 2016 - Forum software by © MyBB