0

我的代码是:

$.validator.addMethod("dateBR", function dateBR(value, element) {

    return /^(?:(?:(?:0?[1-9]|1\d|2[0-8])\/(?:0?[1-9]|1[0-2]))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:(?:(?:31\/0?[13578]|1[02])|(?:(?:29|30)\/(?:0?[1,3-9]|1[0-2])))\/(?:(?:1[6-9]|[2-9]\d)\d{2}))$|^(?:29\/0?2\/(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26]))))$/.test(value);
}

但我只想在需要元素时检查它......我该怎么做?

10倍!!

4

1 回答 1

0

向您的元素添加一个“必需”类:

<input class='required' />

然后循环遍历类名:

$(this).attr('class').split(' ');
于 2009-10-28T16:09:15.757 回答