Skip to content

Instantly share code, notes, and snippets.

@blatyo
Created August 26, 2009 14:43
Show Gist options
  • Select an option

  • Save blatyo/175549 to your computer and use it in GitHub Desktop.

Select an option

Save blatyo/175549 to your computer and use it in GitHub Desktop.
//Put on a text area in java
String action = "'return Event.noBubble( event, RSACommon.limitLength( this, " + maxLength + " ) )'";
javascript = " onkeypress=" + action +
" onkeyup=" + action +
" onkeydown=" + action +
//RSACommon
limitLength: function( elem, maxLength ) {
if( elem.value.length > maxLength ) {
elem.value = elem.value.substring( 0, maxLength );
return false;
}
return true;
}
//
Event.noBubble = function( event, returnCode ) {
event = event || window.event;
event.cancelBubble = true;
if(event.stopPropagation) {
event.stopPropagation();
}
return returnCode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment