0

How to implement field validations and edit mask

asked 2014-09-28 09:09:47 +0800

AAdel gravatar image AAdel
3 1

Dear All

I hope all are OK.

I am new to ZK and I want to implement a field validation such that if the value entered in the filed is not valid, an error message should be displayed and the focus is not transferred to the next field e.g. the focus remains on the filed with incorrect value, and what is the best approach to use, constraints or onChanged event. In case if the constraints is advised, how to implement and call custom constraints implemented in a Java class. I have also another issue , I want to implement an edit mask such that the value entered by a user is formatted before the user leaves the field e.g. if the user is submitting an amount,the entered amount should look like this 123,456.789 even if the filed has the focus and the user did not leave the field.

For your information, I have a legacy PowerBuilder financial application which I am trying to migrate to java. The above mentioned issues were easy to implement in PowerBuilder and I am trying to have the same behavior using ZK.

Best regards;

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2014-09-28 12:03:40 +0800

Darksu gravatar image Darksu
1991 1 4

Hello AAdel,

In order to implement a custom constraint please refer to the following url:

http://books.zkoss.org/wiki/ZKComponentReference/BaseComponents/InputElement#CustomConstraint

Regarding the second question you can find some good examples at the following url:

http://www.zkoss.org/zkdemo/effects/form_effect

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2014-09-28 15:52:45 +0800

chillworld gravatar image chillworld flag of Belgium
5337 4 9
https://github.com/chillw...

Hi AAdel,

Personally I don't like that you can't change the focus until you have the correct value set.

It's easier/better to show the notifications when you press the submit button and the submit button will do nothing.

In this topic you can see how to put regex and internationalisation as constraint.

You can trow also the constraint from java side with a WrongValueException.

Second question : Maybe you could have a look at this.

Greetz chill.

link publish delete flag offensive edit
0

answered 2014-09-30 12:06:57 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2619 3 8
http://emrpms.blogspot.in...

Check here

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
1 follower

RSS

Stats

Asked: 2014-09-28 09:09:47 +0800

Seen: 17 times

Last updated: Sep 30 '14

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