限制文本框输入的长度

ゝ一纸荒年。 2022-09-30 09:55 356阅读 0赞

txtText .Attributes .Add (“onkeyup” , “return isMaxLen(this)” );

txtText .Attributes .Add (“maxlength” , value .ToString ());

< script type =”text/javascript”>

function isMaxLen (o ){

  1. 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) } }

发表评论

表情:
评论列表 (有 0 条评论,356人围观)

还没有评论,来说两句吧...

相关阅读

    相关 QT限制文本框输入方法

    QT限制文本框输入的方法 界面编程的时候,对文本框的处理往往是个很头疼的事情: 一是焦点进入文本框时,从人性化考虑,应选择文本框中文本,方便输入; 二是,限制文本框的