limitCharacts Limit and trim the amount of characters added to any input/textarea tag Use var elem = document.querySelectorAll('input'), limit = 100; limitCharacts(elem,limit); Demo juanbrujo.github.io/limitCharacts