Ajax Form Validation Zend Framework 2?


Staff member
I follow this tutorial:

<a href="http://samsonasik.wordpress.com/2012/10/11/zend-framework-2-using-zend-form-and-ajax/" rel="nofollow">http://samsonasik.wordpress.com/2012/10/11/zend-framework-2-using-zend-form-and-ajax/</a>

I dont want to popup in my code so as per above tutorial code call showform action direct by localhost/ajax_demo/public/testajax/skeleton/showform . while submit this form its call validatepostajax function two time means validate two times and also save data into database two times.

Please help me how to prevent it for submit and validate only for one time.

Thanks in Advance..

My ajax form code is:


                   { 'username'    : $('input[name=username]').val(),
                     'password'    : $('form#loginform input[name=password]').val(),
                     'agree' : $('form#loginform input[type=checkbox]').val()    
                   }, function(itemJson){
                    /*Check error exist or not For each form element and set validation messages HTML*/
                    var error = false;
                    if (!error){                     
                        if (itemJson.success == 1){
                            $("#loginform").prepend('&lt;li class="success"&gt;Login Successfully&lt;/li&gt;');
                    /*Invalid Credentials*/
                   if (itemJson.error == 1){
                            $("#loginform").prepend('&lt;li class="error"&gt;Invalid Credentials&lt;/li&gt;');

            }, 'json');

            return false;

This code is developed on reference above link, but it execute two times. so how can i call it only one time.