Page 1 of 1

Prevent Enter Key to Save Record

Posted: Wed Mar 20, 2024 11:33 pm
by shahparzsoft

The below functino for Prevent Enter Key to Save Record is perfectly working in single Add but not in Grid Add.

Please advise ?

$('body').on('keydown', 'input, select, textarea', function(e) {
var self = $(this)
, form = self.parents('form:eq(0)')
, focusable
, next
, prev
;

if (e.shiftKey) {
if (e.keyCode == 13) {
focusable = form.find('input,a,select,button,textarea').filter(':visible');
prev = focusable.eq(focusable.index(this)-1);

 if (prev.length) {
	prev.focus();
 } else {
	form.submit();
}
}
}
else
if (e.keyCode == 13) {
focusable = form.find('input,a,select,button,textarea').filter(':visible');
next = focusable.eq(focusable.index(this)+1);
if (next.length) {
next.focus();
} else {
form.submit();
}
return false;
}
});

Re: Prevent Enter Key to Save Record

Posted: Thu Mar 21, 2024 9:22 am
by mobhar

For Grid-Add mode, since it is triggered from the List Page, then make sure you have already put your code in Startup Script that belongs to the List Page.