Experts,
I'm writing some JavaScript for a website I'm working on.
I have several text boxes that look similar to these:
A. <input type="text" id="R1C3" OnKeyPress="HideDropDownOnTabPress(event)" />
B. <input type="text" id="R1C4" OnKeyPress="return TextboxKeyPress(event, this)" />
And my JavaScript functions that handle the OnKeyPress events look like this:
function HideDropDownOnTabPress(event)
{
alert('hit');
var keyCode = (event.which) ? event.which : event.keyCode;
alert(keyCode);
if(keyCode == 9)
{
CloseDropDown();
}
}
//Allows only numbers to be entered into textbox
function TextboxKeyPress(event, textbox)
{
var keyCode = (event.which) ? event.which : event.keyCode;
if ((keyCode > 31 && (keyCode < 48 || keyCode > 57)) || keyCode == 13)
return false;
else
return true;
}
The function TextBoxKeyPress() fires in the latest edition of all the major browsers (Firefox, IE8, Chrome, Safari, Opera) and works just fine.
The HideDropDownOnTabPress() function however, does not fire in all browsers. It only works in Firefox and Opera. Chrome, Safari, and IE8 just ignore it.
What am I doing wrong that prevents the HideDropDownOnTabPress() function from firing in Chrome Safari and IE?
What do I need to fix to get this to work.
Thanks.