简体   繁体   中英

jquery.validation() - validation works but no submit

I've encountered this strange situation where jQuery.validation method works - validates the form, but for some reason blocks form submission even if all required conditions are met.

Form HTML and 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(){

});

No error message, no bugs in firebug, no nothing. JS works stable. I've tried to simplify it and try with only 1 input field - the same result. Form works perfectly fine without validation method aplied.

How is this caused and how can I solve it?

Not sure if it will work for you, just try:

$(document).ready(function(){
   $("#create-customer-form").validate({
   submitHandler: function(form) {
   form.submit();
   }
 });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM