D
donpro
Hi,
I have the following function that check for the <Enter> key being
pressed on an <Input> field:
function disableCR(e) {
if (window.event) {
key = window.event.keyCode;
} else {
key = e.which;
}
alert(key);
if (key == 13) {
alert('false');
return false;
} else {
alert('true');
return true;
}
}
My previous HTML was like so:
<input type="text" name="total" value="100" size="6" maxlength="4"
onkeypress="return disableCR(event)">
I would like to convert this into an Event Listener using DOM but not
sure how to do this. Has anyone done this?
I have the following function that check for the <Enter> key being
pressed on an <Input> field:
function disableCR(e) {
if (window.event) {
key = window.event.keyCode;
} else {
key = e.which;
}
alert(key);
if (key == 13) {
alert('false');
return false;
} else {
alert('true');
return true;
}
}
My previous HTML was like so:
<input type="text" name="total" value="100" size="6" maxlength="4"
onkeypress="return disableCR(event)">
I would like to convert this into an Event Listener using DOM but not
sure how to do this. Has anyone done this?