Revision: 50527
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 25, 2011 22:28 by Krummelz
Initial Code
function inputLimiter(e, allow, value) { var AllowableCharacters = ''; if (allow == 'Letters') { AllowableCharacters = ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; } if (allow == 'Numbers') { AllowableCharacters = '1234567890'; } if (allow == 'NameCharacters') { AllowableCharacters = ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.\''; } if (allow == 'NameCharactersAndNumbers') { AllowableCharacters = '1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-\''; } var k; k = document.all ? parseInt(e.keyCode) : parseInt(e.which); if (k != 13 && k != 8 && k != 0) { if ((e.ctrlKey == false) && (e.altKey == false)) { return ((AllowableCharacters.indexOf(String.fromCharCode(k)) != -1) && (value.length < 5)); } else { return true; } } else { return true; } } <input type="text" onkeypress="return inputLimiter(event,'Numbers', this.value)" />
Initial URL
Initial Description
Restricts the characters that are entered into a textbox. Also limits the length of the value to 5.
Initial Title
Javascript Character input restriction script, with length limiter
Initial Tags
javascript
Initial Language
JavaScript