douyaju4749 2016-09-07 23:06
浏览 8
已采纳

当我试图阻止多次点击提交时,验证无效

i have used class='required' for required validation which is working fine when i remove onClick="this.form.submit(); this.disabled=true; from submit button. i want to disable multi click with validation

<form action="<?php echo $this->url('weeklyplan', array('action' => 'add')); ?>" method="post" id='myform'>
    <div class="mainformdiv">
        <div class= "formelementblock">
            <div class="formelement">
                <select name="txtdefined_week_id" id="txtdefined_week_id" class="select-block required"  onchange="showdateranges()">
                    <option value="">Select Defined Week</option>
                    <?php foreach ($definedweeks as $obj) { ?>
                        <option value="<?php echo $obj->defined_week_id; ?>"><?php echo $obj->start_day . "-" . $obj->end_day; ?></option>
                    <?php } ?>
                </select>
            </div>
        </div>

        <div class= "formelementblock">
            <div class="formelement">
                <input type="text"  readonly="readonly" name="txtstart_date" class="input-text datepickerwidth required" id="txtstart_date" placeholder="Start Date*"/>
            </div>

        </div>
        <div class= "formelementblock last">
            <div class="formelement">
                <input type="text" readonly="readonly"  name="txtend_date" class="input-text datepickerwidth required" id="txtend_date"  placeholder="End Date*"/>
            </div>
        </div>
    </div>

    <div class="clear"></div>
    <div class="form-button">
        <div class="button-block">
            <input onClick="this.form.submit(); this.disabled=true;" class="button" type="submit" name="button" id="button" value="Save" />&nbsp;&nbsp;&nbsp;
            <input class="button" type="button" name="button" id="button" value="Cancel" onclick="window.location = '<?php echo $this->url('weeklyplan', array('action' => 'index')); ?>'" />
        </div>
    </div>
</form>

展开全部

  • 写回答

2条回答 默认 最新

  • droos02800 2016-09-08 03:21
    关注
    $(document).ready(function() {
            $("#button").click(function(){
                $('#button').attr('disabled',true);
                $('#myform').submit();
                var no=$("#myform").validate().toShow.length;
                if(no!=0){
                    $('#button').attr('disabled',false);
                }
    
            });
        });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 KeiI中头文件找不到怎么解决
  • ¥15 QT6将音频采样数据转PCM
  • ¥15 本地安装org.Hs.eg.dby一直这样的图片报错如何解决?
  • ¥15 下面三个文件分别是OFDM波形的数据,我的思路公式和我写的成像算法代码,有没有人能帮我改一改,如何解决?
  • ¥15 Ubuntu打开gazebo模型调不出来,如何解决?
  • ¥100 有chang请一位会arm和dsp的朋友解读一个工程
  • ¥50 求代做一个阿里云百炼的小实验
  • ¥15 查询优化:A表100000行,B表2000 行,内存页大小只有20页,运行时3页,设计两个表等值连接的最简单的算法
  • ¥15 led数码显示控制(标签-流程图)
  • ¥20 为什么在复位后出现错误帧