[英]validation not working in Firefox but works in IE,Chrome
I use the following java script function for integer validate which means the text box can allow to enter only the integer values alone. 我将以下Java脚本函数用于整数验证,这意味着文本框仅允许输入整数值。 * It was work fine in Internet explorer and google chrome * .But I use this same function in FireFox the text box didn't allow to enter any characters in that which means it doesn't allow characters,numbers,space,anything else..How to solve this problem?
* 在Internet Explorer和google chrome中都可以正常工作 。但是我在FireFox中使用了相同的功能,因此文本框中不允许输入任何字符,这意味着它不允许使用字符,数字,空格或其他任何内容。 。如何解决这个问题呢?
javascript function javascript功能
$('.intValidate').live('keypress', function(event) {
var integervalidate = intValidate(event);
if (integervalidate == false)
return false;
});
function intValidate(event) {
if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||(event.keyCode == 65 && event.ctrlKey === true) ||(event.keyCode >= 35 && event.keyCode <= 39))
{
return;
}
else
{
if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 ))
{
event.preventDefault();
}
I use the class like , 我使用像这样的课程
<input type="text" id="abcd" style="width:30px" maxlength="2"class="intValidate""/>
You're examining keycodes in the keypress
event. 您正在检查keypress事件中的
keypress
代码。 You should be looking at charCode
values instead. 您应该改为查看
charCode
值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.