0

我遇到了 jQuery.validation 方法起作用的这种奇怪情况 - 验证表单,但由于某种原因,即使满足所有必需条件也会阻止表单提交。

表单 HTML 和 JS:

<div id="createcustomer">
<form method="POST" action="http://localhost/actionurl..." id="create-customer-form">
    <div class="input-table">
        <div class="input-row">
            <div class="input-cell-label" >
                Skrót (Kod)
            </div>
            <div class="input-cell">
                <input type="text" id="input-shortname" name="shortname" class="required" maxlength="25" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Pełna nazwa
            </div>
            <div class="input-cell">
                <input type="text" id="input-fullname" name="fullname" class="required" maxlength="255" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Adres
            </div>
            <div class="input-cell">
                <input type="text" id="input-address" name="address" class="" maxlength="90" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Kod pocztowy
            </div>
            <div class="input-cell">
                <input type="text" id="input-postal_code" name="postal_code" class="" maxlength="6" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Miasto
            </div>
            <div class="input-cell">
                <input type="text" id="input-city" name="city" class="" maxlength="45" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Państwo
            </div>
            <div class="input-cell">
                <input type="text" id="input-country" name="country" class="required" maxlength="45" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Telefon
            </div>
            <div class="input-cell">
                <input type="text" id="input-phone" name="phone" class="" maxlength="45" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Faks
            </div>
            <div class="input-cell">
                <input type="text" id="input-fax" name="fax" class="" maxlength="45" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Email
            </div>
            <div class="input-cell">
                <input type="text" id="input-email" name="email" class="" maxlength="45" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell-label" >
                Strona www
            </div>
            <div class="input-cell">
                <input type="text" id="input-website" name="website" class="" maxlength="45" value="" />
            </div>                    
        </div>
        <div class="input-row">
            <div class="input-cell" >
            </div>
            <div class="input-cell" >
                <input type="submit" name="submit_create" value="Utwórz" class="submit"/><input type="Reset" value="Wyczyść" />
            </div>
        </div>
    </div>
</form>

<script>



$(function(){ 

    $("#create-customer-form").validate();

});

$(document).ready(function(){

});

没有错误消息,萤火虫中没有错误,什么都没有。JS 工作稳定。我试图简化它并尝试仅使用 1 个输入字段 - 结果相同。表单在没有应用验证方法的情况下工作得很好。

这是如何引起的,我该如何解决?

4

1 回答 1

1

不确定它是否适合您,请尝试:

$(document).ready(function(){
   $("#create-customer-form").validate({
   submitHandler: function(form) {
   form.submit();
   }
 });
});
于 2013-02-18T13:45:03.777 回答