Jquery 表单批量验证

给表单批量添加验证

Form表单的ID

  var self = $("#FormID");

表单验证内容

function ValiForm(self) {
    var res = true;
    self.find('.required').each(function () {
        if (!$(this).val()) {
            $(this).prop('required', true);
            $(this).css('border-color', 'red');
            res = false;
        } else {
            $(this).css('border-color', '#ccc');
        }
    });
    return res;
}

 

posted @ 2021-07-29 11:53  幽冥狂_七  阅读(95)  评论(0编辑  收藏  举报