0

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........." }
            }
        })
3
  • Does the element have a class="required" on it? Commented Aug 25, 2010 at 10:25
  • yes I do have a required class on the textbox using CSSClass property of ASP.NET textbox Commented Aug 25, 2010 at 10:31
  • I have multiple classes on the textbox namely class="txtOtherReasonDescription required" as the output in the html Commented Aug 25, 2010 at 10:35

1 Answer 1

1

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.

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.