[老题新问]如何在输入全角中文的情况下限制textarea的最大输入长度?(解决就结贴)
这个问题其实很老了。因为textarea的mexlenth不好用,所以只能用脚本(vbscript)实现。
我写了个脚本如下:
Sub txtBIKOU_OnKeyDown
If Len(Document.all.txtBIKOU.value) > 512 Then
Document.all.txtBIKOU.value = Left(Document.all.txtBIKOU.value, 512)
End If
End Sub
Sub txtBIKOU_OnMouseMove
If Len(Document.all.txtBIKOU.value) > 512 Then
Document.all.txtBIKOU.value = Left(Document.all.txtBIKOU.value, 512)
End If
End Sub
但是因为这个输入框规定必须输入全角中文,所以当达到512的时候,如果继续输入将会把所有文字清空,从头开始输入!
我想可能是因为当键盘点击的时候,文字并没有写入textarea,所以长度判断不出来。
不知道那位大哥有好办法啊?