普通网友 2014-11-15 14:44
浏览 43
已采纳

如何在jQuery php中验证后在提交表单上禁用“锚点”

I have a small problem, a form on submit is being validated then I am sending it but I need to disable my submit button onClick if validation is successfull here is my button code

 <button type="submit" class="btn btn-primary " id="submitBtn"><i class="fa fa-envelope"></i> Kişi Kayıt</button>

and here is my jQuery code

..... here is validation codes .....
submitHandler: function(form) {

$.ajax({
    url: 'plugin/clientIssues.php?tU=1',
    type: "POST",
    data: $('#userReg').serialize(),
    success: function(response) {
               alert(response); // show response from the php script.

               window.setTimeout('location.reload()', 300);
             }            
     });
    return false;
    $form.submit();
 }
});

Do you have any idea where I can put

$('#submitBtn').hide();

if the validation is correct and pressed on submit button ?

  • 写回答

1条回答 默认 最新

  • dousui3124 2014-11-15 14:45
    关注

    In your success function:

    success: function(response) {
               alert(response); // show response from the php script.
               $('#submitBtn').hide();
               window.setTimeout('location.reload()', 300);
             }
    

    Although I'd (personally) just disable the button:

    success: function(response) {
               alert(response); // show response from the php script.
               $('#submitBtn').attr('disabled','true');
               window.setTimeout('location.reload()', 300);
             }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面