日期:2014-05-16  浏览次数:20395 次

验证问题!
怎样验证输入的内容已5278开头并且位数为10位。

------解决方案--------------------
<script language=vbscript>
...
aa=...
if len(trim(aa)) <> 10 then
msgbox "有误 "
else
if left(aa,4) <> "5278 " then
msgbox "有误 "
end if
end if
...

</script>
------解决方案--------------------
/^5278(\d{6})$/.test( "5278666666 ")
------解决方案--------------------
<html>
<head>
<title> 数字验证 </title>
</head>
<body>
<script >
function regex()
{
var regex=/^5278\d{6}$/g;
var str = document.form1.name1.value;
var result = regex.test(str);
alert(result);
}
</script>
<form name=form1>
<input type=text name=name1 >
<input type=button onClick= "regex() " value= "test ">
</form>
</body>
</html>

------解决方案--------------------
/^5278(\d{6})/gi