Sweetalert and jQuery.validationEngine

241 views Asked by At

I have implemented Sweetalert on my jQuery.validationEngine but the button "Accept" of sweetalert doesn't run the "submit", What could add to make it work?

This is the code with Sweetalert:

                    $(document).ready(function(){
            $("#id_form").validationEngine('attach',{
            onValidationComplete:function(form, status){
            if (status === true){
            if(swal({title: "Confirm text?",text: "Another Text",type: "warning",showCancelButton: true,confirmButtonColor: "#DD6B55",confirmButtonText: "Accept",cancelButtonText: "Cancel"closeOnConfirm: true,closeOnCancel: false})){       

        form.validationEngine('detach');
           submit();
                }}}
            });
           })

Without Sweetalert and running:

            $(document).ready(function(){
            $("#id_form").validationEngine('attach',{
            onValidationComplete:function(form, status){
            if (status === true){
                if(confirm("Confirm text?")){               

        form.validationEngine('detach');
           submit();
                }}}
            });
        }) 

References:

Sweetalert

jQuery.validationEngine

1

There are 1 answers

0
mehmet cinar On

first of all you should insert comma after "Cancel" string. Adapt your code according to below

swal({
                                title: "Confirm text?",
                                text: "Another Text",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "Accept",
                                cancelButtonText: "Cancel",
                                closeOnConfirm: true,closeOnCancel: false
                            }, function (isConfirm) {
                                if (isConfirm) {
                                    return true;
                                } else {
                                    return false;
                                }
                            });