日期:2014-05-16 浏览次数:20483 次
<script type="text/javascript">
function test(inputVal)
{
//去除首尾空格
inputValinputVal = inputVal.replace(/^\s*|\s*$/g,"");
//零长字串不作处理
if ( inputVal.length == 0 )
{
return;
}
//只能匹配数字,字母或汉字
var _match = inputVal.match(/^[a-zA-Z0-9\u4e00-\u9fa5\(\)()、;/]+$/g);
//匹配数字或字母(包括大小写)
var codeMatch = inputVal.match(/[a-zA-Z0-9]/g);
//匹配汉字
var charMatch = inputVal.match(/[\u4e00-\u9fa5]/g);
//数字或字母个数
var codeNum = codeMatch ? codeMatch.length : 0;
//汉字个数
var charNum = charMatch ? charMatch.length : 0;
//成功
if ( _match && codeNum + 2*charNum <= 50 )
{
return;
}
//失败
alert("请确认输入字符是否超过25个!");
}
//-->
</script>
<script type="text/javascript">
function test(inputVal)
{
//去除首尾空格
inputValinputVal = inputVal.replace(/^\s*|\s*$/g,"");
//零长字串不作处理
if ( inputVal.length == 0 )
{
return;
}
//只能匹配数字,字母或汉字
var _match = inputVal.match(/[A-Z]/g);
//匹配大写字母
if ( _match == 0 )
{
alert("请确认字母为大写!");
}
return;
}
//-->
</script>