0

I am trying to validate the following form using jQuery plugin but not successful yet. Please help me with the issue.

<ol>
        <li>
            <label for="address1" class="biz">Address 1<span class="required">*</span></label>
            <input id="address1" name="address[address1]" class="text" type="text" >
        </li>
        <li>
            <label for="address2" class="biz">Address 2</label>
            <input id="address2" name="address[address2]" class="text" type="text"/>
        </li>
        <li>
            <label for="city" class="biz">City<span class="required">*</span></label>
            <input id="city" name="address[city]" class="text" type="text"/>
        </li>

goes on....

rules: {
        name: { required: true },
        phone: { required: true },
        address: { required: true },                                                                        
}

The above rule is not working. Thank you guys in advance.

1
  • Where to begin... First, what jQuery plugin are you trying to use? Also, is this all of your code? Commented Jan 20, 2010 at 5:10

1 Answer 1

1

You need to use the full field names and quote them. REF: http://docs.jquery.com/Plugins/Validation/Reference#Fields_with_complex_names_.28brackets.2C_dots.29

$("#form").validate({
    rules: {
        "address[address1]": { required: true },
        "address[address2]": { required: true },
        "address[city]": { required: true },
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.