【问题标题】:Regex jquery正则表达式 jquery
【发布时间】: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
});
}

【问题讨论】:

    标签: jquery regex


    【解决方案1】:

    应该这样做:

    function chkText() {
        $(".cssText").each(function() {
            if (/^[A-Za-z0-9!@#]{5,20}$/.test(this.value)) {
                // valid input value
            } else {
                // invalid input value
            }
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-02
      • 2012-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多