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

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

        });
    });

You are using html5 form validation. If you want to check if the inputs are valid before submit you have to change the:

<input onClick="this.form.submit(); this.disabled=true;" class="button" type="submit" name="button" id="button" value="Save" />

To something like:

<input onClick="checkform(); this.disabled=true;" class="button" type="button" name="button" id="button" value="Save" />

Notice that the button is not a 'submit' type but rather a normal button. With this you can create a javascript function ("checkform()") that checks if the inputs are valid. There is a function in javascript that returns whether an input with the 'required' html5 attribute is valid. This function is:

inputElement.checkValidity()

After you checked if all inputs are valid you can submit the form.