0

我已经实现了表单验证,当我单击提交按钮时,整个页面都会刷新。

但我的任务是提交表单并仅停留在该页面上。

这是下面的代码,请建议我如何实现。

enter code here
\\ Formvalidation code
     }
}).on('success.form.fv', function (e) {

    //e.preventDefault();
    //fv = $(e.target).data('formValidation'); // FormValidation instance\

    //fv.disableSubmitButtons(false);

    //InternaryTicketInvoiceSave();

    var $form = $(e.target),
   $button = $form.data('formValidation').getSubmitButton(),
   $statusField = $form.find('[name="status"]');

    switch ($button.attr('id')) {

        case 'btnTicketSave':
            InternaryTicketInvoiceSave();
            break;
        case 'UpdateStatus':
            InternaryTicketInvoiceSave();
            chnageSatatus();
            break;
       }


     });


     }
    //view code
     <form id="Iform" name="Iform" method="post">
        \\view code here
     </form>
4

2 回答 2

0

使用 html 5 验证,即示例示例

 <form action="demo_form.asp" method="post">
      <input type="text" name="fname" required>
 <input type="email" name="email" required placeholder="Enter a valid email address">
      <input type="submit" value="Submit">
    </form>

详细 http://www.the-art-of-web.com/html/html5-form-validation/

于 2016-05-20T09:25:58.777 回答
0

我错过了 e.preventDefault();

于 2016-05-20T09:44:26.307 回答