How to block the form from saving

I have a requirement to show the error message and not to save the form if the list and library control does not have any record.
How to block the form saving based on fd.control("SPDataTable2").widget.dataItems().length == 0?

Thank you in advance.

Hello @annesha_adhikari,

The following code checks the entries in the 'List or Library' and not allows a user to save the record if the control has no items.

Please use it in the 'JavaScript' Editor.


fd.spRendered(function() {

		name: 'SPDataTable validator',
	    error: 'Error message',
	    validate: function() {
	        if (fd.control("SPDataTable0").widget.dataItems().length == 0) {
	            this.error = "Add at least one record to the table";
	            return false;

	        return true;

1 Like

Thank you very much. It works for me.

1 Like