Jun 222012
 

Look at the line 26 to 31.

I have add validation if some condition is fulfill.

var validator = $("#deal").validate({
    rules: {
                    dealName: "required",
                    dealCategoryId: "required",
                    dealPhone: {
                                    required: true,
                                    digits:true
                    },
                    dealVenueName: "required",
                    dealVenueAddress: "required",
                    dealVenueStateId: "required",
                    dealVenueZip: {
                                    required: true,
                                    minlength: 5,
                                    digits:true
                    },
                    dealVenueContactEmail: {
                                    required: true,
                                    email: true
                    },                                             
                    dealVenueWebSite: {
                                    url: true
                    },
                    dealStartDate: "required",
                    dealEndDate: "required",
                    dealPrice: {required: function(element){
                      return document.getElementById('dealIsFree').checked != true}
                    },
                    dealTicketOnSaleDate: {required: function(element){
                      return document.getElementById('dealIsFree').checked != true}
                    },
    },
    messages: {
                    dealName: "Please enter a deal name",
                    dealCategoryId: "Please select a category",
                    dealPhone: {
                                    required: "Please enter phone no",
                                    digits:  jQuery.format("Please enter only digits")
                    },
                    dealVenueName: "Please enter venue name",
                    dealVenueAddress: "Please enter venue address",
                    dealVenueStateId: "Please select a state",
                    dealVenueZip: {
                                    required:  "Please enter a zipcode",
                                    minlength:  jQuery.format("Please enter at least {0} characters"),
                                    digits:  jQuery.format("Please enter only digits")
                    },
                    dealVenueContactEmail: {
                                    required:  "Please enter a contact email address",
                                    email: "Please enter a valid email address"
                    },
                    dealVenueWebSite: {
                                    url: "Please enter a valid website URL"
                    },
                    dealStartDate: "Please select a start date",
                    dealEndDate: "Please select a end date",
                    dealPrice: "Please enter price",
                    dealTicketOnSaleDate: "Please select a date"
    },
    
    // set this class to error-labels to indicate valid fields
    success: function(label) {
                    // set   as text for IE
                    label.html(" ").addClass("checked");
    }
});