Created
September 24, 2012 17:55
-
-
Save danwoods/3777297 to your computer and use it in GitHub Desktop.
Restrict the number of characters in an input/textarea
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
// onkeyup="restrictchars(this, someInteger)" | |
var restrictChars = function(elm, maxLen){ | |
var len = elm.value.length; | |
if(len >= maxLen){ | |
elm.value = elm.value.substring(0, maxLen); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment