<div class="font-limit">
<input type="text" id="username" autoComplete='off' maxlength="17" onkeyUp="textLimitCheck(this, 17);" placeholder="请输入17位车架号">
<span class="js_limit">
<em id="messageCount">0</em>/<span>17</span>
</span>
<span style="margin-left: 2%;"><img src="img/ercode.png" style="width: .17rem;"></span>
</div>
//文字限制
function textLimitCheck(thisArea, maxLength){
if (thisArea.value.length > maxLength){
alert(maxLength + ' 个字限制. \r超出的将自动去除.');
thisArea.value = thisArea.value.substring(0, 17);
thisArea.focus();
} /*回写span的值,当前填写文字的数量*/
messageCount.innerText = thisArea.value.length;
}