Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TextItem's setKeyPressFilter regular expression problem

    GWT version: 2.04
    SmartGwt 2.3 version: 2.4
    Firefox version: 4.0.1
    Eclipse version: 3.6
    Windows XP SP3

    I'm trying to restrict keyboard input on given TextItem to signed integers by using the argument "[-+]?[0-9]+" in setKeyPressFilter method. But i cannot enter the '-' or '+' characters.

    (The source code at http://www.smartclient.com/smartgwt/...eypress_filter at the second text item says only numeric values but someone can enter the dot '.')
    Last edited by Nikd; 17 Jun 2011, 23:59.

    #2
    The keypress filter is not not a full regular expression of the field format but a single expression to match each character against. So [0-9] would limit each character to a digit. Something like [0-9][a-z] would never work because only one character is matched against it at a time.

    So, limit your keypresses to the valid characters that can be entered anywhere in the field and use a regex validator to confirm the overall value is correct.

    Comment


      #3
      Thanks for the explanation. I have already 'switched' to reg exp validators.

      Comment

      Working...
      X