Home >Web Front-end >JS Tutorial >js code about text word limit_form effects
When working on a project, I write a piece of js for everyone. Regarding the problem of limiting the number of characters in text, it is often used in actual development; the main problem occurs in the restriction of Chinese. The following code solves the verification problem of limiting the number of bytes; just save this code to a js file and Introduce it into the verification page and you can use it! At the same time, I hope you will give me your strong support and valuable opinions. I will publish more good articles in my spare time in the future, thank you! !
/*
value: value;
byteLength: database byte length
title: Chinese name of field
attribute: attribute name
Instructions for use:
Add (1) onkeyup="limitLength(this.value,100,'name','name')"
(2) id="name" or [struts tag] styleId="name"
Note: id name and attribute The attribute names should be the same
Example: