The code below is super simple, I won’t say much more, just go to the code.
//输入计数 //count:能輸入的數據總量 function Calculation(v, count) { var span = $(v).next(); var valLength = $(v).val().length; if (valLength > count) { $(v).val($(v).val().substr(0, count)); valLength = count; } span.text("您已輸入" + valLength + "字元,還剩下" + (count - valLength) + "字元"); }
The above code uses JavaScript to calculate how many characters can be entered into the text box. I hope you like it.