0

Datebox onChanging Clear text

asked 2017-06-19 09:49:58 +0800

ofaruk gravatar image ofaruk
5 1

I have a datebox, I want that when a letter is typed datebox is cleared, only works with integer values, I designed it like that, but I cannot erase or clear datebox content

 private EventListener<? extends InputEvent> birthDateConstraint() {
        return new EventListener<InputEvent>() {
            @Override
            public void onEvent(final InputEvent event) throws Exception {
                String str = event.getValue();
                if(str.matches(".*[a-zA-Z]+*.")) {
                    birthDate.setContext("");
                }
            }
        };
    }
delete flag offensive retag edit

Comments

cor3000 thanks, but it works for once, second time cannot clears

ofaruk ( 2017-06-21 07:14:29 +0800 )edit

I am not sure what you are trying to achieve... constraints don't work that way

cor3000 ( 2017-06-21 07:33:59 +0800 )edit

you could reset the rawValue like in this fiddle http://zkfiddle.org/sample/pkgq6n/1-clear-db-on-wrong-key still I'd recommend looking into implementing a normal a real constraint as described here: https://www.zkoss.org/wiki/ZKComponentReference/Base_Components/InputElement#Constraint

cor3000 ( 2017-06-21 07:45:42 +0800 )edit

thanks for replay, reseting rawValue works thaks a lot

ofaruk ( 2017-06-21 09:50:57 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-21 02:53:09 +0800

cor3000 gravatar image cor3000
4366 2 7
ZK Team

updated 2017-06-21 02:55:01 +0800

calling birthDate.setContext(""); will only clear the associated context menu id and not the value (see XulElement.setContext())

In order to clear the value of a <datebox> you have to call Datebox.setValue()

birthDate.setValue(null);
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2017-06-19 09:49:58 +0800

Seen: 14 times

Last updated: Jun 21 '17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More