普通网友 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);
             }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下