限制文本框输入的长度
txtText .Attributes .Add (“onkeyup” , “return isMaxLen(this)” );
txtText .Attributes .Add (“maxlength” , value .ToString ());
< script type =”text/javascript”>
function isMaxLen (o ){
var nMaxLen = o .getAttribute ? parseInt (o .getAttribute ("maxlength" )) : "" ;
if (o .getAttribute && o .value .length >nMaxLen ){
o .value =o .value .substring (0,nMaxLen )
}
}
</ script >
maxlength=10 function isMaxLen(o){ var nMaxLen=o.getAttribute? parseInt(o.getAttribute(“maxlength”)):””; if(o.getAttribute && o.value.length>nMaxLen){ o.value=o.value.substring(0,nMaxLen) } }
还没有评论,来说两句吧...