Prevent submission

how to stop submitting the editview form? I am using v7.10.

return false in before_save doesn’t seem to be working, and also I need something like a pop-up to notify the user that the submission was not successfully submitted.

I solved this problem by removing all unnecessary attributes of the SAVE button using jQuery.

You can submit it again by using this

check_form(‘EditView’); // in my case, i used this inside $("#btn’).click() because I needed some validation before I can proceed.

Since this could be useful to programmers, could you please share in detail, including complete code inserted in code tags, filenames/paths affected as well as a clear description of the issue?

Remove save button’s default attributes using jQuery

$("#SAVE.button.primary").removeAttr('accesskey');
$("#SAVE.button.primary").removeAttr('onclick');
$("#SAVE.button.primary").removeAttr('type');
$("#SAVE.button.primary").attr('type', 'button');

Then, if you need some validation trigger it using jQuery.click event

$('#SAVE.button.primary').click(function(event){

      if( conditions ){
           // logic
      }
      else {
          var _form = document.getElementById('EditView');
	   _form.action.value = 'Save';
       
           if (check_form('EditView')){
		SUGAR.ajaxUI.submitForm(_form); // this will submit the form
	   }
      }
     

});
1 Like