Limit number of characters allowed in form input text field

https://raw.githubusercontent.com/edwardlorilla/VuejsEssentials/857bdb4c3e2f5e81345ba1b733b72846622b8eb9/index.html
{{remain}}/{{limit}}
 h1, div, p, span {
            font-size: 18px;
            font-family: helvetica;
        }
        body {
            padding: 33px;
        }
        span {
            line-height: 20px;
        }
        input {
            line-height: 20px;
            font-size: 18px;
            width: 96px;
        }
        .warning {
            border: red solid 2px;
        }
new Vue({
        el:'#app',
        data:{
            message:'',
            limit:9,
        },
        computed:{
            remain:function(){
                return this.limit - this.message.length
            }
        },
        methods:{
            check:function(){
                if(this.remain<0){
                    this.message = this.message.substr(0,this.limit)
                }
            }
        },
    })

No comments:

This will make you a better decision maker | Annie Duke (author of “Thinking in Bets” and “Quit”, former pro poker…

Annie is a former professional poker player, decision-making expert, author, and special partner at First Round Capital.  ͏     ­͏     ­͏   ...

Contact Form

Name

Email *

Message *