0

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?

3
  • You should create a jsfiddle.net for it for live demo Commented Feb 18, 2013 at 13:40
  • Nvm. That's not a closure, but shorthand for ready event handler apparently. Commented Feb 18, 2013 at 13:44
  • jsfiddle.net/tbYbn - it works here. Only thing that comes to my mind is that there is a conflict with another plugin Commented Feb 18, 2013 at 14:00

1 Answer 1

1

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

$(document).ready(function(){
   $("#create-customer-form").validate({
   submitHandler: function(form) {
   form.submit();
   }
 });
});
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot - it worked, still it seems like a workaroud. I still have no idea why wouldn't it work as in the example above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.