Textarea input word number prompt

Time:2021-4-10
LimitedNnumber('.eventBox', '.viewBox', 50)

/*
*Eventbox: input box ID or class
*Viewbox: prompt element ID or class
*Textlength: limit length
*/
function LimitedNnumber(eventBox, viewBox, textLength) {
   $(document).on('input propertychange paste keyup', eventBox, function(event){
      this.value = this.value.replace(this.value.slice(textLength), "")
      $(viewBox).html(this.value.length +"/"+ textLength)
   })
}