<script language="javascript"> //获得字符串字节数,中文占2个字符
String.prototype.bLength=function(){
return this.replace(/[^\x00-\xff]/g,"..").length;
}
var str="啊";
var re=/\s+/g;
if(str.replace(re,"")=="")
{
alert("标题不能为空!");
}else
{
var blen = str.bLength();
if(blen<4 || blen>120)
{
alert("标题必须在4-120个字符之间!");
}
}</script>
String.prototype.bLength=function(){
return this.replace(/[^\x00-\xff]/g,"..").length;
}
var str="啊";
var re=/\s+/g;
if(str.replace(re,"")=="")
{
alert("标题不能为空!");
}else
{
var blen = str.bLength();
if(blen<4 || blen>120)
{
alert("标题必须在4-120个字符之间!");
}
}</script>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货