[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

mutipe rules in form validation

Hi
I'm using jquery.validate.js . I have the following code in the head
  <script type="text/javascript">
      $.metadata.setType("attr", "validate");  
 
      $(document).ready(function(){
        $("#subscriptionForm").validate({
          rules: {
            cemail: "required email",
            cemail_again: {
              equalTo: "#cemail" ,
                    
                   cpassword: "required password",
                  cpassword_again: {
              equalTo: "#cpassword"
                        }
                  }
          }
        });
      });
  </script>

If I place more than one rule in this code, only one part works, (i,e., the form will check that the two email fields match, or that the 2 passwords match, not both sets. So, if I omit the password code, the email works fine, and visa versa. Can anyone help? Here is a link to the form, http://www.districtadministration.com/layouts/subscriptions/print_subscribe.html

Thank you in advance,
Sharon
0
promediagrp
Asked:
promediagrp
1 Solution
 
HainKurtSr. System AnalystCommented:
try this
$(document).ready(function(){
$("#subscriptionForm").validate({
	rules: {
		cemail: "required email",
		cemail_again: {
			equalTo: "#cemail"
		},
		cpassword: "required password",
		cpassword_again: {
			equalTo: "#cpassword" 
		}
	}
});
});

Open in new window

0
 
promediagrpAuthor Commented:
Thank you very much. That was quick and easy.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now