How to only allow digits to be entered in a textbox?

42 views
Skip to first unread message

membersound

unread,
Jan 7, 2013, 9:55:44 AM1/7/13
to google-we...@googlegroups.com
Hi,

I have a textbox where I want to user to only enter digits. Moreover I want to prevent him entering other characters. This is what I tried but it does not work:

    @UiHandler("textbox")
    void onInputsKeyPress(KeyPressEvent event) {
        if (!Character.isDigit(event.getCharCode())) {
            ((IntegerBox) event.getSource()).cancelKey();
        }
    }


Any hints?

RyanZA

unread,
Jan 8, 2013, 9:49:27 AM1/8/13
to google-we...@googlegroups.com
Grab this code from stackoverflow, should do what you want

http://stackoverflow.com/questions/2865647/solution-for-numeric-text-field-in-gwt
Reply all
Reply to author
Forward
0 new messages