`

Bootstrap-maxlength 使用

 
阅读更多

Demo:http://mimo84.github.io/bootstrap-maxlength/

 

用法

1 给页面上的 input 或者 textarea 标签加上maxlenght 属性

<input type="text" name="nickname" maxlength="20" id="nickname">

 

2配置一些选项

    <script type="text/javascript" >
    $(document).ready(function(){
    $('input#defaultconfig').maxlength()
        $('input#nickname').maxlength({
        alwaysShow: true,
        });

        $('textarea#msg').maxlength({
        alwaysShow: true
        });

    });
    </script>

 

3别忘记引入 js文件  jquery 需要1.9以上版本

 

    <script src="/static/js/bootstrap-maxlength.js"></script>
    <script src="/static/js/bootstrap-maxlength.min.js"></script>


 

最后效果图

 

当然还有很多选项可以配置见  插件主页

 

  • 大小: 12.1 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics