/*
	This section implements client-side validation using various plugins.
	
	Please add plugins to this list for custom validation (decimal, AJAX validation, etc.)
	
	You need to change the 'rules' section to point to your fields (match id and name attributes).
	You also need to implement the SubmitHandler if the form should AJAX post to a CNP Post URL.
	
*/
        
        // USE THE ID OF THE FORM TO BE VALIDATED BELOW
        // YOU MAY ALSO CUSTOMIZE THE CONTAINER AND WRAPPERS FOR INVALID ITEMS
            $("#sweeps_jjtangles").validate({
                wrapper:"li",
                errorLabelContainer:"#errorbox",
                focusInvalid:false,
        // SETUP THE FIELDS AND VALIDATION TYPES HERE
                rules:{
                    firstname:{
                        required:true,
                        maxlength:50
                    },
                    lastname:{
                        required:true,
                        maxlength:50
                    },
                    dob_m:{
                        required:true
                    },
                    dob_d:{
                        required:true
                    },
                    dob_y:{
                        required:true
                    },
                    address1:{
                        required:true,
                        maxlength:100
                    },
                    city:{
                        required:true,
                        maxlength:50
                    },
                    stateprov:{
                        required:true
                    },
                    zippostal:{
                        required:true,
                        number:true,
                        maxlength:12
                    },
                    email:{
                        required:true,
                        email:true
                    },
                    tele1:{
                        required:true,
                        number:true
                    },
                    tele2:{
                        required:true,
                        number:true
                    },
                    tele3:{
                        required:true,
                        number:true
                    }
                    
                },
        // SET THE DISPLAY MESSAGES FOR EACH FAILED VALIDATION BELOW
                messages:{
                    firstname: "First name is required.",
                    lastname: "Last name is required.",
                    address1: "Address 1 is required.",
                    city: "City is required.",
                    stateprov: "State or province is required.",
                    zippostal: "Zip code is required, and must be numeric.",
                    email: "E-mail address is required, and must be valid.",
                    tele1: "Please provide a full phone number",
                    tele2: "Please provide a full phone number",
                    tele3: "Please provide a full phone number",
                    q3: "Please indicate whether you would like to be contacted by Johnson &amp; Johnson.",
                },
        // IF CLIENT-SIDE VALIDATION PASSES, USE THIS FUNCTION TO SUBMIT THE FORM AND HANDLE ANY ADDITIONAL CONDITIONS
                submitHandler:function(thisform){
                    // This should potentially provide some sort of 'please wait' functionality (spinner, hide the submit button, etc.)
                    
                    // This value controls whether or not the form will be submitted at the end of this handler
                    var returnValue = true;
                    
                    // CNP POST URL VALIDATION - USE AN ASP OR PHP PROXY TO SUBMIT TO CNP
                    thisform.submit();
                }
            });