2010-08-25 120 views
0

我使用校验失败的自定义消息下面,但我得到了默认的消息...什么是错的?或者我错过了什么?我得到默认的消息......但不是我的自定义消息jQuery的验证插件

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

该元素上是否需要“class =”? – 2010-08-25 10:25:04

+0

是我有使用ASP.NET文本框的CssClass属性的文本框所需的类 – chugh97 2010-08-25 10:31:46

+0

我对文本框,即类=“txtOtherReasonDescription需要”作为HTML输出它没有工作......它采用 – chugh97 2010-08-25 10:35:10

回答

1

既然你似乎是使用ASP.Net从命名约定,给这一个尝试,而不是:

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

验证插件期待一个元素,而不是ID的,所以使用.UniqueID而不是.ClientID在这里得到控制的名称。

+0

由于多个类$而不是_ – chugh97 2010-08-25 10:36:53