【问题标题】:Bootbox validation error message not appear in firefox but not chromeBootbox 验证错误消息不会出现在 Firefox 中,但不会出现在 chrome 中
【发布时间】:2021-05-22 02:23:05
【问题描述】:

标题描述了问题,我创建了一个fiddle 来显示问题。

$("input[name='delete']").click(function(e) {
  e.preventDefault();
  bootbox.confirm("Are you sure?", function(result) {
    if (result) {

      // form validation
      if (document.getElementById("student_delete_form").reportValidity()) {
         $('#student_delete_form').submit();
      }
    }
  });
});

预期结果: chrome 和 firefox 上的验证错误消息

实际结果:验证错误信息只出现在firefox上而不是chrome上

【问题讨论】:

    标签: javascript jquery google-chrome firefox bootbox


    【解决方案1】:

    解决了!原来if语句应该在bootbox之前

    $("input[name='delete']").click(function(e) {
      e.preventDefault();
      // form validation
      if (document.getElementById("student_delete_form").reportValidity()) {
        bootbox.confirm("Are you sure?", function(result) {
          if (result) {
            $('#student_delete_form').submit();
          }
        });
    
      }
    });
    
    $('#student_delete_form').on('submit', function() {
      alert('I am submitted!');
    })
    
    

    我还为遇到与我相同问题的任何人更新了小提琴

    【讨论】:

      猜你喜欢
      • 2013-11-21
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      • 1970-01-01
      • 1970-01-01
      • 2017-09-28
      • 2016-08-31
      相关资源
      最近更新 更多