【发布时间】:2017-04-12 19:54:37
【问题描述】:
我必须验证以下场景:“15AB12” 条件:(1) 第一个元素应该是 1 + 一个数字 + 两个字母 + 2 个数字。我需要为文本框验证这一点。这是我的代码。我不知道我错过了哪里!!!
<label>Username(6):</label>
<input id='username' type='text'>
<p id="p2"></p>
<button id="submit" onclick= "pepe(); return false"">ChecForm</button>
<script>
function pepe(){
if (!($("#username").val().match(/^1\[a-zA-Z0-9]{5}/)))
document.write(" true");
else
document.write("false");
}
</script>
【问题讨论】:
-
当问题与此插件无关时,请不要使用 jQuery Validate 标签。已编辑。
标签: javascript regex validation