0 Replies - 4230 Views - Last Post: 20 August 2017 - 12:47 AM

#1 aidenkael   User is offline

  • D.I.C Regular
  • member icon

Reputation: 65
  • View blog
  • Posts: 299
  • Joined: 22-October 13

Char Remaining Counter

Posted 20 August 2017 - 12:47 AM

Something I cooked up real fast for a website I am working on, feel free to use it, modify it, whatever you want!

function checkRemaining(elementName, alertElement, maxChar, alertThreshold) {
    var element = document.getElementById(elementName);

    if (element) {
        if ($(element).val().length >= (maxChar - alertThreshold - 1)) {
            document.getElementById(alertElement).innerText = maxChar - $(element).val().length - 1 + ' Remaining';
        }
    }
}



Note: Javascript isn't my first (or second) language, so if you do modify it, feel free to tell me why so I can learn too!

Is This A Good Question/Topic? 0
  • +

Page 1 of 1