How can we restrict the user to add a blank row?

Hi
I am looking for a way, where I can restrict the user to add a blank row in a child table.
I have a scenario where I want to restrict the user to add a blank row in a child table and if the row is blank, it should delete the empty row from the table.

Here is my code but it is giving error on remove:

frappe.ui.form.on('Prefix Details', {
prefix_details_add: function(frm) {
if(!frm.doc.prefix_to_be_used)
{
frappe.msgprint("Prefix to be used cannot be left blank");
cur_frm.get_field("prefix_details").grid.grid_rows[1].remove()
refresh_field("prefix_details");
}
else
{
frappe.meta.get_docfield("Prefix Details", "prefix").default = frm.doc.prefix_to_be_used;
}
    }
    }); // End of Frappe.ui add for prefix

Regards
Ruchin Sharma

Did you try to make fields mandatory? In that case user cant add an empty row …