开发者

jQuery.validator.methods.required()

开发者 https://www.devze.com 2022-12-10 10:37 出处:网络
my code is : $.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?[135

my code is :

$.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);
}

but I want to check it only if the Element is required ... how can I do it ?

10X !!


Add a class of 'required' to your element:

<input class='required' />

Then loop through the class names with:

$(this).attr('class').split(' ');
0

精彩评论

暂无评论...
验证码 换一张
取 消