Javascript验证在移动设备上不起作用

Javascript验证在移动设备上不起作用,javascript,jquery,mobile,Javascript,Jquery,Mobile,我使用了一些javascript进行验证,例如,只允许数字或文本,限制长度。它在桌面上运行良好,但在手机上,下面提到javascript不起作用 /// allow numbers only $('#pincode, #billing_phone').keypress(function (e) { //if the letter is not digit then display error and don't type anything if (e.which != 8 &

我使用了一些javascript进行验证,例如,只允许数字或文本,限制长度。它在桌面上运行良好,但在手机上,下面提到javascript不起作用

 /// allow numbers only  
 $('#pincode, #billing_phone').keypress(function (e) {
 //if the letter is not digit then display error and don't type anything
  if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
   //display error message
   return false;
  }
});


//allow characters only
 $(function() {
$("#billing_first_name, #billing_last_name").keydown(function(e) {
  if ( e.which != 9) {
    var key = e.keyCode;
    if (!((key == 8) || (key == 32)  || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
      e.preventDefault();
    }
  }
});
});

// restrict length
$("#reg_billing_city").attr('maxlength',30);
$("#billing_phone, #reg_billing_phone, .qty").attr('maxlength',10);
///仅允许数字
$(“#pincode,#billing#u phone”)。按键(功能(e){
//如果字母不是数字,则显示错误,不键入任何内容
如果(e.which!=8&&e.which!=0&&e.which<48 | e.which>57)){
//显示错误消息
返回false;
}
});
//仅允许使用字符
$(函数(){
$(“#账单名,#账单姓”)。向下键(函数(e){
如果(例如,哪个!=9){
var key=e.keyCode;

如果(!((key==8)| |(key==32)| |(key==46)| | |(key>=35&&key=65&&key)是web和mobile中的键码相同…?是的,一切都相同,我已在浏览器中检查(移动分辨率)它可以正常工作,但在实际的移动设备中它不能正常工作。在网络和移动设备中,键码是一样的吗?是的,一切都一样,我已经检查了浏览器(用于移动分辨率),它可以正常工作,但在实际的移动设备中它不能正常工作
if (screen.width < 600) {// javascript goes here }