限制<input>、<textarea>标签输入的字符串长度
↑GIF https://i.postimg.cc/X7tmdMmz/type-Limit-Length.gif
限制<input>、<textarea>标签输入的字符串长度(英文记1长度,中文记2长度)
依赖Jquery
Limit the string length of <input>/<textarea> tag when input
require jquery
Get Started<!-- include jQuery -->
<script type="text/javascript" src="https://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<!-- include typeLimitLength.js-->
<script type="text/javascript" src="/dist/typeLimitLength.min.js"></script>
<!-- include typeLimitLength.css-->
<link rel="stylesheet" type="text/css" href="/dist/typeLimitLength.css" />
Usage
HTML
<div id="countWrap"></div>
<input type="text">
JS
$("input").typeLimitLength({
'maxLength': 40, //限制输入长度 (默认:40)
'countWrap': "#countWrap", //将计数放在哪个容器中 (默认:空)
});
OR
HTML
<div id="countWrap_"></div>
<textarea count-wrap="#countWrap_" maxlength="50"></textarea> <!--将参数写在属性中-->
JS
$("textarea").typeLimitLength();
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。