jQuery技术:JavaScript Submithandler问题

$("#myform").validate({ submitHandler: function (form) { var cboxes = ($('input:checkbox:checked').filter(":checked").length); var nboxes = ($(":checkbox:not(:checked)").length); var flag = false; if ((cboxes > 0) && (nboxes > 0)) { flag = confirm('You have Checked only few locations among the List. n Are you sure, you do not want to Prescribe from the other locations? '); } else if (cboxes == 0) { alert('Please select atleast One Address n Where you would prefer to prescribe from.'); } else { flag = true; } return flag; } }); 

如果我点击确定弹出确认框,它应该接受提交,但事实并非如此。

谁能告诉我为什么会这样?

    form.submit替换return flag

     $("#myform").validate({ submitHandler: function (form) { var cboxes = ($('input:checkbox:checked').filter(":checked").length); var nboxes = ($(":checkbox:not(:checked)").length); var flag = false; if ((cboxes > 0) && (nboxes > 0)) { flag = confirm('You have Checked only few locations among the List. n Are you sure, you do not want to Prescribe from the other locations? '); } else if (cboxes == 0) { alert('Please select atleast One Address n Where you would prefer to prescribe from.'); } else { flag = true; } if(flag) form.submit(); } }); 

    如果您没有使用AJAX,这就是.validate()文档中描述的方式。

    需要了解更多jQuery教程分享JavaScript Submithandler问题,都可以关注jQuery技术分享栏目—计算机技术网(www.ctvol.com)!

      以上就是jQuery教程分享JavaScript Submithandler问题相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/982311.html

      (0)
      上一篇 2021年12月13日
      下一篇 2021年12月13日

      精彩推荐