erolkaya84 erolkaya84 - 2 months ago 25
Java Question

GWT - How to allow only numbers in TextItem?

I have the following

TextItem
:

final TextItem txtFromAmt = new TextItem();
txtFromAmt.setWrapTitle(false);
txtFromAmt.setShowTitle(false);
txtFromAmt.setAlign(Alignment.LEFT);
txtFromAmt.setWidth(100);


I want this
TextItem
to only allow numbers. How can I do that? Is there any property/method of
TextItem
to do that?

Answer

Please check the below documentation.

https://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/TextItem.html#setKeyPressFilter-java.lang.String-

As suggested by El Hoss try the same

txtFromAmt.setKeyPressFilter("[0-9.]"); // allows only digits and .(dot)
Comments