<script language="JavaScript">
<!--
function CheckScript(theForm)
{
if(theForm.loginname.value.length > 50){
alert("会员登录名不能大于50个字符,请重新输入!");
theForm.loginname.select();
theForm.loginname.focus();
return (false);
}
}
//-->
</script>
<!--
function CheckScript(theForm)
{
if(theForm.loginname.value.length > 50){
alert("会员登录名不能大于50个字符,请重新输入!");
theForm.loginname.select();
theForm.loginname.focus();
return (false);
}
}
//-->
</script>
解决方案 »
- 问几个javascript创建function的问题?
- 'rows' 为空或不是对象
- 哪行代码有阴影效果的啊?郁闷
- 怎么点击一个链接文字(add)后.链接文字变为(ok).
- 可不可以通过JS往浏览器地址栏写URL进去
- 我想在一个页面中如果URL是有’?‘的,我下面的连接也带上?test可以这样吗?
- 求教:有没有办法用JavaScript更新xml文件
- 高分求救, 低难度(我是菜鸟), 高分数(你是高手)
- 如果在运行中设置框架网页的宽度?
- bootstrap-datepicker隐藏时触发bootstrap的modal的隐藏事件
- 打开窗口时怎样控制其高和宽
- 请教一个浮点化数值的问题!(高手都来侃侃)(不好意思,我只有10的可用分,明天加)
javascript将中文字符算作一个字符,所以如果输入50个中文,他不会判断出错,但实际上已经是100个字符了。
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function strLen(txtstr){
return txtstr.replace(/[^\x00-\xff]/g,"xx").length;
}
test.value=strLen("gq事业a业")
//-->
</SCRIPT>
<script>
function calLen(strText)
{
var nLen = 0;
for(var i = 0; i < strText.length;i++)
{
if(strText.charCodeAt(i) > 128)
nLen = nLen + 2;
else
nLen++
}
return nLen;
}
</script>
String.prototype.lenb = function() {
return this.replace(/[^\x00-\xff]/g,"**").length;
}