GWT:make text limit on RichTextArea and stop user enter more characters
I am using GWT RixhText Area and want to put a limit on 100 characters in
the richText Area .
right now i am doing this .
description.addKeyDownHandler(new KeyDownHandler(){
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER ||
event.getNativeKeyCode() == KeyCodes.KEY_UP ||
event.getNativeKeyCode() == KeyCodes.KEY_LEFT||
event.getNativeKeyCode() == KeyCodes.KEY_DOWN ||
event.getNativeKeyCode() == KeyCodes.KEY_BACKSPACE||
event.getNativeKeyCode() == KeyCodes.KEY_SHIFT) {
}else{
if(description.getText().trim().length()>100){
Window.alert("You have reached your maximum limit");
}
}
}});
Now when 100 characters reached it works fine, give me the alert but how
can i stop user from entering more characters , it shows the alert but
also takes the input .. how to stop this ..
Secondly I am using this css below to move to the next line itself when
area ends.. it works fine .. but if a user just hold down the key on
keyboard and don't release this css doesn't works , not taking to next
line and goes on .. is there a solution for this
CSS:
break-word {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
thanks
No comments:
Post a Comment