Stop form submit then shoot from modal

0

I have a form that by clicking to send I show a modal to confirm, I could do the same with an alert but for reasons of aesthetics I show a modal that has a button, that button confirms the sending of the form

I would like the modal button to trigger the form, how could I do this with jquery

I have the following:

                                                     

Buyer Data

                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Unde, vel odio non dicta provident sint ex autem mollitia dolorem illum repellat ipsum aliquid illo similique sapiente fugiat minus ratione.</p>



    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-body">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                        <h4 class="modal-title" id="myModalLabel">Confirmar compra</h4>
                                    </div>
                                    <div class="modal-body">
                                        <p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
                                        <p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
                                        <p>
                                            <a href="" class="button button-3d notopmargin fleft" id="comprar" >Proceder a la compra</a>
                                        </p>
                                        <p>&nbsp;</p>



                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>   

 <form method="POST" action="proceso.php" accept-charset="UTF-8" 
 id="procesar"><input name="_token" type="hidden" 
 value="Lj6ETkI7zq0lLWcu4nX2pGHh3kQeX6RpuazUIzHY">

    <div class="col_half">


        <label for="billing-form-name">Nombre</label>
        <input class="sm-form-control" name="addressline" type="text">

    </div>

    <div class="col_half col_last">
        <label for="billing-form-lname">Apellido</label>
        <input class="sm-form-control" name="billing-form-lname" type="text" 
        id="billing-form-lname">

    </div>

    <div class="form-group">
        <label for="ruc">RUC / CI</label>
        <input class="form-control" name="ruc" type="text" id="ruc">
    </div>


    <input class="button success" id="proc_cart" data-toggle="modal" data-
    target=".bs-example-modal-lg" type="submit" value="Procesar pedido">
    </form>

Then my script would be:

   <script type="text/javascript">

     var custom2=jQuery;
     custom2.noConflict();

     custom2(document).ready(function() {

        custom2( "#proc_cart" ).click( function(event){
            event.preventDefault();

        });

        custom2( "#comprar" ).click( function(event){

            $("#procesar").trigger('submit');

            //alert('hola');
        });
    });

</script>
    
asked by Leoh 22.08.2017 в 15:34
source

1 answer

1

Try adding this line event.preventDefault(); remaining like this

custom2( "#comprar" ).click( function(event){
        event.preventDefault();
        $("#procesar").trigger('submit');

        //alert('hola');
    });

If this does not help you, what error is he giving you to clarify a bit more? I hope it helps you test your code and this was what was missing.

    
answered by 22.08.2017 / 16:31
source