How to prevent form from submitting?

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

    e.preventDefault();
    e.stopImmediatePropagation();
    return false;

preventing it from submitting?

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();
});

formAjaxBeforeSend will never stop ajax,you should valid input before $.post

Yes, it is impossible to prevent it in such events, just use manual form sending with all the required validation

But I need to check if “publicera” is checked, then they have to have written a “price”. How can I do that?
Thanks Vladimir.

Only by remove form auto send functionality, collecting form data manually, manually validating it and manually sending it.

Ok, so just do a check and then, $$(’#formid’)submit(); to send it, is that right syntax?

No, use Request to send data via xhr http://framework7.io/docs/request.html

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...??
});