Why is this not preventing the form from submitting?
Im trying to prevent it from submitting if the checkbox(publicera) IS check and the input(price) is NOT checked.
Why is not
Im getting the alert, but the form is still submitted.
Thanks.
$$('#sparaprodukter.form-ajax-submit').on('formajax:beforesend', function (e) {
//should this be checkbox[name=publicera ??
var publicera=$$(document).find('input[name=publicera]').prop()
if((publicera).is(':checked')){
app.dialog.alert("Skriv ett pris!","ÅTERVINN MERA")
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
app.preloader.show();
});
I have also tried this, but its the same.
app.on('formAjaxBeforeSend', function (formEl, data, xhr) {
var publicera=$$(document).find('input[name=publicera]').prop()
if((publicera).is(':checked')){
app.dialog.alert("Skriv ett pris!","ÅTERVINN MERA")
formEl.preventDefault();
formEl.stopImmediatePropagation();
return false;
}
app.preloader.show();
});
Ok, I have to test, I think my problem is that Im using a file upload component on my server that gets the images from the form field and Im not sure it works if I send it with a ajax request. Maybe it works the same, I have to test tomorrow. Thanks.
So I can’t get this code to work at all?
$$( "#sparaprodukter" ).submit(function( event ) {
var publicera=$$(document).find('input[name=publicera]').prop()
console.log(publicera)
app.dialog.alert("Skriv ett pris!","ÅTERVINN MERA")
event.preventDefault();
event.stopImmediatePropagation();
return false;
}
app.preloader.show();
$$('#sparaprodukter').submit();
//prevent the page from actually navigate to the page Im submitting the form to...??
});