一开始input中可输入内容的要求都写到后台,实际上可以在前端js中加正则验证
//var LengNum=Request.Form["otherjudge"].Tostring().Length;
//var LengNum = OtherJudge.Length;
//if (LengNum > 7)
//{
// req.msg = "最多可输入7个汉字!";
// req.code = 1;
//}
js:
<input autocomplete="off" class="layui-input" onkeyup="value = value.replace(/[^u4E00-u9FA5]/g, '')" onbeforepaste=" clipboardData.setData('text', clipboardData.getData('text').replace(/[^u4E00-u9FA5]/g, ''))" maxlength=7 name="otherjudge" id="otherjudge">