在jquery中,将文本框验证为数字
In jquery validation for textbox as numeric
只对数值进行用户ID验证!这是我的代码,请告诉我我的代码哪里出错了
function login() {
UserID = $('#txtLoginScreen_UserId').val();
password = $('#txtLoginScreen_MPIN').val();
if (UserID.length == 0) {
alert("Please enter User ID");
} else if (password.length == 0) {
alert("Please enter MPIN");
}
/* Here am unable to make USer ID validation for restricting only numeric values upto 12 */
/* else if (isNaN(parseInt($("#txtLoginScreen_UserId").val()))) {
alert('It must be numbers');
return false;
}*/
/* Validate for UserID */
/* $("#txtLoginScreen_UserId").keypress(function(e) {
alert("validate");
//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
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
*/
else {
}
if()$.isNumeric(UserID){
} else{
alert("not numaric");
}
试试这个,
if (parseInt(UserID) > 0) {
alert("Please enter alphanumeric characters only");
}
相关文章:
- 我应该使用什么正则表达式来验证数字模式
- 仅在jQuery验证中验证数字、括号和空格
- 验证数字是否在0.00到20.00之间的正则表达式
- 用于验证数字范围的正则表达式
- 如何验证数字是否为整数
- javascript/jQuery:使用 .each 时验证数字
- 仅验证数字字符的 PDF 表单字段
- 欧芹.js - 仅验证数字的可选输入
- 如何在Javascript中使用正则表达式来验证数字
- 如何使用Javascript针对0.5增量验证数字
- 使用javascript中的常规exp验证数字,但在一种情况下不起作用
- 验证数字Javascript
- Javascript验证数字xhtml
- Angular JS-如何验证数字输入中的位数
- 用短划线angularjs验证数字
- 验证数字并允许空格
- Javascript 正则表达式,用于验证数字是否以前导零开头
- 如何在javascript中验证数字输入
- 在Javascript中验证数字
- JavaScript -仅验证数字/字母