开发者

jQuery.validator.methods.required()

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜