Home >Web Front-end >JS Tutorial >js code about text word limit_form effects

js code about text word limit_form effects

WBOY
WBOYOriginal
2016-05-16 19:16:06991browse

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:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn