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

时间:2014-11-15 14:44:17

标签: javascript php jquery html forms

我有一个小问题,提交表单正在验证然后我发送它但我需要禁用我的提交按钮onClick如果验证成功,这里是我的按钮代码

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

这是我的jQuery代码

..... 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();
 }
});

你知道我可以放在哪里

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

如果验证正确并按下提交按钮?

1 个答案:

答案 0 :(得分:0)

在你的成功功能中:

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

虽然我(个人)只是禁用按钮:

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