给表单批量添加验证

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;
}

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2021-07-15
  • 2021-09-07
  • 2021-06-14
  • 2021-06-09
猜你喜欢
  • 2021-09-26
  • 2021-12-20
  • 2022-01-18
  • 2021-10-25
相关资源
相似解决方案