netscape时,onkeypress的问题,解决即结贴,急!
判断text1的onkeypress事件,只允许输入数字,现在用ie时正常,用netscape时,虽然text1只能输入数字了,但如果页面上还有其它输入框,在改变text1值后其它输入框也只能输入数字了,而我只要求text1输入数字,其它输入框可以输入字符的,下面的我的脚本,高手们帮帮忙!特别急!谢谢!
<asp:TextBox id="text1" runat="server" onkeypress="FilterKey(this)">
function FilterKey(objValue)
{
var IE6 = ((document.all)&&(navigator.appVersion.indexOf('MSIE')!=-1)) ? true : false;
if (IE6 == true) //如果是IE
{
var kcode = window.event.keyCode;
if(kcode >= 48 /* '0'*/ && kcode <= 57 /* '9'*/ ){
return;
}
window.event.returnValue = false;
}
else //netscape时
{
document.onkeypress = keyPress;
}
}
function keyPress(e)
{
var kcode = e.which;
if((kcode >= 48 /* '0'*/ && kcode <= 57 /* '9'*/ ) || (kcode==0) || (kcode==8))
{
return;
}
return false;
}