Lyan Dwi Pangestu
Lyan Dwi Pangestu

Reputation: 473

[validation]ajax submit

I use this engine enter link description here

And I use $.ajax to send the value. When i submit the form with empty value the validation is work but it doesn't stop the $.ajax send

this is the validation:

<script type="text/javascript" src="../validate/jquery.validationEngine-en.js"></script>
$(document).ready(function() { $("#form_tambah").validationEngine(); });

this my $.ajax send :

$.ajax({
            type:"POST",
            url:"proses.php",
            data:$("form[name=form_tambah]").serialize(),
            success : function(msg){
                $('div[id=result]').html("<p>"+msg+"</p>");

            }
        })
        return false;

How o solve it..? thanks before

Upvotes: 0

Views: 305

Answers (1)

Frans Wines
Frans Wines

Reputation: 11

Try this

jQuery("#form_Envia_Seq_Doc").validate({
    rules: 
    {
        dt1: {
            required: true,
            dateBR: true
        },
        dt2: {
            required: true,
            dateBR: true
        } 
    },
    messages: 
    {
        dt1: 'Informe uma Data Válida',
        dt2: 'Informe uma Data Válida'
    },

    submitHandler: function( form ) { 
        /*var dados = $( form ).serialize();  */
        //jQuery("#progress").show();    
        /*jQuery('#form_Envia_Seq_Doc').submit(function(){*/
        var action = jQuery('#form_Envia_Seq_Doc').attr('action');
        //alert("1");
        var erro = false;
        //Verifica se esse seq_doc já foi informado
        jQuery(".dataTable input[type=hidden]").each(function(){
            var value=jQuery(this).val();
            if(value == jQuery("#seq_doc").val())
            {
                alert("Seq_doc já informado");
                erro = true;
                jQuery("#progress").hide();
                return false;
            }
        });
    }
});

Upvotes: 1

Related Questions