Welcome Guest, Not a member yet? Register   Sign In
codeigniter form validation and jquery form validation problem
#7

[eluser]simshaun[/eluser]
Try this:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
[removed][removed]
[removed][removed]
[removed][removed]
&lt;link href="&lt;?php echo base_url().'/system/static/css/f_propreg1.css'; ?&gt;" rel="stylesheet" type="text/css" /&gt;
&lt;link href="../../static/css/f_propreg1.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;

&lt;body&gt;

New User Registration

&lt;?php echo form_open('replace_this_with_the_action', array('id' => 'c_f_propreg1_username_v1')); ?&gt;

[removed]
// JavaScript Document
$(document).ready(function(){
    $('#title').focus();

    $('#c_f_propreg1_username_v1').validate({
        rules: {
            email: {
                required: true
                ,email: true
            }
            ,username: {
                required: true
                ,rangelength: [6,12]
            }
            ,pwd: {
                required: true
                ,rangelength:[6,12]
            }
            ,terms: {
                required: true
            }
            ,conf_pwd: {
                equalTo:'#pwd'
            }
            ,spam: {
                required: true
            }
        } // end rules
        ,messages: {
            email: {
                required: "This field is Required."
                ,email: "This is not a valid email address."
            }
            ,username: {
                required: "This field is Required."
                ,rangelength: "Username must be between 6 and 12 characters long."
            }
            ,pwd: {
                required: "This field is Required."
                ,rangelength: "Password must be between 6 and 12 characters long."
            }
            ,conf_pwd: {
                equalTo: "The two passwords do not match."
            }
            ,terms: {
                required: "Please accept our Terms and Conditions"
            }
        } //end messages
    }); // end validate
}); //end ready
[removed]

<fieldset><legend>Your Name</legend>

    <div><label for="title">Title</label></div>
    <select name="title" id="title" class="required" value="&lt;?php echo set_value('title'); ?&gt;" title="Please select your Title">
        <option value="">--Select Title--</option>
        <option value="Mr"&lt;?php echo set_select('title', 'Mr'); ?&gt; >Mr</option>
        <option value="Mrs"&lt;?php echo set_select('title', 'Mrs'); ?&gt;>Mrs</option>
        <option valuwd="Miss"&lt;?php echo set_select('title', 'Miss'); ?&gt;>Miss</option>
        <option value="Ms"&lt;?php echo set_select('title', 'Ms'); ?&gt;>Ms</option>
    </select>
    *<span class="phperror">&lt;?php echo form_error('title'); ?&gt;</span>

    <div><label for="firstname">First Name:</label></div>
    &lt;input name="first_name" type="text" class="required" id="first_name" title="Please enter your First Name" value="&lt;?php echo set_value('first_name'); ?&gt;" size="50" maxlength="70" /&gt;
    *<span class="phperror">&lt;?php echo form_error('first_name'); ?&gt;</span>

    <div><label for="lastname">Last Name:</label></div>
    &lt;input name="last_name" type="text" id="last_name" value="&lt;?php echo set_value('last_name'); ?&gt;" size="50" maxlength="50" class="required" title="Please enter your Last Name" /&gt;
    *<span class="phperror">&lt;?php echo form_error('last_name'); ?&gt;</span>

</fieldset>

<fieldset><legend>Login and Password</legend>
    Fields marked with an Asterick are mandatory

    <div><label for="email">Please Enter your E-mail Address</label></div>
    &lt;input name="email" type="text" value="&lt;?php echo set_value('email'); ?&gt;" id="email" /&gt; *<span class="phperror">&lt;?php echo form_error('email'); ?&gt;</span>

    <div><label for="username">Choose a Username</label></div>
    &lt;input name="username" type="text" id="username" value="&lt;?php echo set_value('username'); ?&gt;" size="15" maxlength="12" /&gt;
    * Min 6 chars-Max 12 chars<span class="phperror">&lt;?php echo form_error('username'); ?&gt;</span>

    <div><label for="pwd">Choose a Password</label></div>
    &lt;input name="pwd" type="password" id="pwd" value="&lt;?php echo set_value('pwd'); ?&gt;" size="15" maxlength="12" /&gt;
    * Min 6 chars - Max 12 chars<span class="phperror">&lt;?php echo form_error('pwd'); ?&gt;</span>

    <div><label for="conf_pwd">Re-enter Password</label></div>
    &lt;input name="conf_pwd" type="password" id="conf_pwd" value="&lt;?php echo set_value('conf_pwd'); ?&gt;" size="15" maxlength="12" /&gt;
    * Min 6 chars - Max 12 chars<span class="phperror">&lt;?php echo form_error('conf_pwd'); ?&gt;</span>

    <div><label for="passwordhint">Password Hint</label></div>
    &lt;input name="Passwordhint" type="text" id="passwordhint" value="&lt;?php echo set_value('passwordhint'); ?&gt;" maxlength="20" /&gt;

    <p> Accept our Terms and Conditions
    &lt;input name="terms" type="checkbox" value="1"&lt;?php echo set_checkbox('terms','1'); ?&gt; id="terms" /&gt;
    *<span class="phperror">&lt;?php echo form_error('terms'); ?&gt;</span></p>
</fieldset>

&lt;input name="" type="submit" /&gt;

&lt;?php echo form_close(); ?&gt;

&lt;/body&gt;
&lt;/html&gt;

I'm assuming your syntax for the config is correct.


Messages In This Thread
codeigniter form validation and jquery form validation problem - by El Forum - 11-25-2008, 10:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB