views:

19

answers:

1

I am using the following for a custom message for validation failure but I am getting the default message...What is wrong? or am I missing something? I get the default message ...but not my custom message

$("#commentForm").validate({
            rules: {
                insurance1_ucBuildingInsurance_txtOtherReasonDescription: "required"
            },
            messages: {
                insurance1_ucBuildingInsurance_txtOtherReasonDescription: { required: "Please enter a other reason........." }
            }
        })
+1  A: 

Since you appear to be using ASP.Net from the naming convention, give this a try instead:

$("#commentForm").validate({
  rules: {
    insurance1$ucBuildingInsurance$txtOtherReasonDescription: "required"
  },
  messages: {
    insurance1$ucBuildingInsurance$txtOtherReasonDescription: { 
      required: "Please enter a other reason........." 
    }
  }
});

The validation plugin expects the name of an element, not the ID, so use .UniqueID rather than .ClientID to get the control names here.

Nick Craver
Thanks it did work...It uses $ instead of _
chugh97