【发布时间】:2009-04-08 14:38:27
【问题描述】:
我想用 min char=5, max=20 验证一个 texbox,允许字母和数字,并且只有 3 个特殊字符!@# 使用纯 jQuery(无插件)
function chkText() {
$(".cssText").each(function() {
// add regex condition here in an IF statement
});
}
【问题讨论】:
我想用 min char=5, max=20 验证一个 texbox,允许字母和数字,并且只有 3 个特殊字符!@# 使用纯 jQuery(无插件)
function chkText() {
$(".cssText").each(function() {
// add regex condition here in an IF statement
});
}
【问题讨论】:
应该这样做:
function chkText() {
$(".cssText").each(function() {
if (/^[A-Za-z0-9!@#]{5,20}$/.test(this.value)) {
// valid input value
} else {
// invalid input value
}
});
}
【讨论】: