Welcome Guest, Not a member yet? Register   Sign In
Prevent double insert at same time
#12

(This post was last modified: 01-17-2025, 12:17 AM by pippuccio76.)

(01-16-2025, 11:20 AM)michalsn Wrote: A much cleaner way would be using
Code:
type="submit"

for your button, and then something like:

Code:
$("#myform").submit(function(e) {
    e.preventDefault();

    var scegli_materiali = $("#scegli-materiali").val();
    var quantita = $("#id_class_quantita").val();

    if (scegli_materiali == "") {
        alert('Scegli un codice!!!!');
    } else if (quantita == '') {
        alert('Inserisci una quantità');
    } else {
        $("#bottone_invio_form").prop("disabled", true);
        $("#bottone_invio_form").hide();
        $("#gif_animata").show();

        // Proceed with form submission
        this.submit();
    }
});


Anyway, for your existing code - try to add this in your final condition:

Code:
$(this).prop("disabled", true);

$(this).hide();

$("#gif_animata").show();

$("#myform").submit();

Oh... and consider whether it's worth taking advantage of the native validation you get when you use "required" tags in your input forms.
But I expect you have a reason for doing it the way you are doing it now.

hi , i think that with this code i cannot resolve double insert on db , i must insert a validation to control if data with determinate condition are sending to db and if the time is equals i don't insert record...

i also think that ci developer must create a standard validation to prevent this by passing an array of value to control  (with created_at).
Reply


Messages In This Thread
RE: Prevent double insert at same time - by cha - 01-16-2025, 02:24 AM
RE: Prevent double insert at same time - by pippuccio76 - 01-17-2025, 12:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB