jQuery Bootstrap通知阻止提交表单

问题描述 投票:0回答:1

我让jQuery通知根据某些选择发布警告消息:我需要做的是在警告/通知消息出现时不要提交表单。仅当错误解决后,才提交表单。单击btnQuoteVariances时,将提交表单。问题是notify不是函数,因此我不能在这里真正使用return false或event.preventDefault()。

$('.Reason').change(function(event)
{
    var id = $(this).data('item-id');
    var sPrice = $(this).data('price');
    var reason = $(this).val();
    var aPrice = $(this).data('aPrice');


    if (reason > 0 && (aPrice == sPrice)){

        $('##' + id).notify(
        {
            title: 'Warning',
            text: "Both pricing can't match, Please fix before conitniuing.",
            image: '<i class="fa fa-2x fa-exclamation-circle"></i>'
        },
        {
            style: 'cosentino',
            className: 'error',
            position: 'top center',
            clickToHide: true,
            autoHide: false
        });

    }

   $('##frmJobEntry').validate(
    {
        errorClass: 'JoblineInlineError'
    });

    $("##btnQuoteVariances").click(function(event)
    {

        $('.txtShopPrice').prop('disabled', false);
        $('.txtRevisedUnitPrice').prop('disabled', false);



    });
jquery notify
1个回答
0
投票

也许

$("form").on("submit",function(e) {
  const $reason = $(".reason");
  const id = $reason.data('item-id');
  const sPrice = $reason.data('price');
  const reason = $reason.val();
  const aPrice = $reason.data('aPrice');
  if (reason > 0 && (aPrice == sPrice)){
    e.preventDefault();
  }  
})
© www.soinside.com 2019 - 2024. All rights reserved.