/ Published in: JavaScript
this function returns if the passed string is shorter than the limit or not when you press keys other than F5, backspace, or any arrow keys and the limit is reached it shows an alert.
use with isValueInArray function
Expand |
Embed | Plain Text
function validateLength(event, limit, str) { notTooLong = true; okKeyCodes = new Array(8, 116, 37, 38, 39, 40); if (str.length >= limit && !(isValueInArray(okKeyCodes, event.keyCode))) { alert("text area limit reached"); notTooLong = false; } return notTooLong; }
You need to login to post a comment.
