mercredi 15 juillet 2015

Bootbox dialog - Checking for saving data

The code below is similar to an example from the following link : http://ift.tt/MXoLKs

Example Name: Custom HTML Forms

bootbox.dialog({
  message: '<div class="row">  ' +
           '<div class="col-md-12"> ' +
           '<form class="form-horizontal"> ' +
           '<div class="form-group"> ' +
           '<label class="col-md-4 control-label" for="awesomeness">Table ID: </label> ' +
           '<div class="col-md-4">' +
           '<input id="idtable" type="text" value="'+table_column_15+'"/>' +
           '</div><br>' +
           '</div>'+
           '</form> </div>  </div>',
  title: "Form",
  buttons: {
    success: {
      label: "Save",
      className: "btn-success",
      callback: function() {
                            console.log('save');
                            console.log($('#re_confirm')[0].checked);
                            var valueid = document.getElementById('idtable').value
                            if(valueid == 0)
                              myFunction();
                            var valueid2 = document.getElementById('idtable').value

                               $.ajax({
                               url : "<?php echo base_url(); ?>http://ift.tt/1I1GSdD",
                               type: "post",
                               data: {
                                   "table_id" : $('#idtable').val(),
                               },
                               success: function(response){
                                   ...
                               }
                           });
      }
    },
    ...
    ,
    ...
  }
});

I would like to know how to check and stop the data from being sent and saved in the database if the textbox with id 'idtable' has still has a value of 0 at the end (after the alert box pop-up).

Please tell me how to do it by giving me the code using this example given above.

I have just started on web development and I don't have much experience. I would be very thankful to you if you can give me a good answer and solve my problem. Thank you very much in advance.




Aucun commentaire:

Enregistrer un commentaire