Trying to write some online invoicing software and want to prevent submitting partially filled form with enter. Used the solutions on the net, ie
stuck onkeydown='noenter();' on inputs and added some jscript:
function noenter()
{
var x = event.which || event.keyCode;
if (x == 13) return false;
}
Put same event code in the jscript on submit form validation and eventually got it to almost work by sticking onkeydown on ALL controls, even disabled ones, but if a control has been selected (even a disabled one!) and then enter is pressed it submits.
Sounds trivial I know, but this is for a severely untechy person and it needs to be foolproof as possible. Any ideas why having a selected control causes the jscript to be ignored? Cheers.
stuck onkeydown='noenter();' on inputs and added some jscript:
function noenter()
{
var x = event.which || event.keyCode;
if (x == 13) return false;
}
Put same event code in the jscript on submit form validation and eventually got it to almost work by sticking onkeydown on ALL controls, even disabled ones, but if a control has been selected (even a disabled one!) and then enter is pressed it submits.
Sounds trivial I know, but this is for a severely untechy person and it needs to be foolproof as possible. Any ideas why having a selected control causes the jscript to be ignored? Cheers.
Comment