Created
August 15, 2014 14:10
-
-
Save GuiSevero/9bf2c0792b714605ce25 to your computer and use it in GitHub Desktop.
Javascript character counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fieldname, warningname, remainingname, maxchars | |
function CheckFieldLength(fn,wn,rn,mc) { | |
var len = fn.value.length; | |
if (len > mc) { | |
fn.value = fn.value.substring(0,mc); | |
len = mc; | |
} | |
document.getElementById(wn).innerHTML = len; | |
document.getElementById(rn).innerHTML = mc - len; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment