给动态生成的html元素添加验证事件(基于jquery的验证组件)

找到需要绑定的元素,用add添加验证事件

elementId = "#xxxxxxxxx_" + rowID;
if ($(elementId).rules().required == undefined) {
if (!$(elementId).hasClass("ui-disabled")) {
$(elementId).rules("add",
{
required: true,
maxlength: 2000,
messages: { required: "Please enter a description", maxlength: "Description cannot be longer than 2000 characters" }
});
}

 

posted @ 2022-11-04 17:10  gds111789  阅读(56)  评论(0编辑  收藏  举报