Prevent Enter Key to Save Record

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
shahparzsoft
User
Posts: 361

Prevent Enter Key to Save Record

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

mobhar
User
Posts: 11727

Post 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.


Post Reply