0

How to customize constraints in textbox

asked 2009-01-24 22:26:23 +0800

judacoor gravatar image judacoor
280 1 3 8

Hi everyone,

I haven't been able to fully understand how the custom constraints in textboxs work, in a past thread a fellow forum member explained to me how to validate an email you should put:

constraint="/.+@.+\.+|/: Please enter a valid email"
. But I did not understand how it works, I mean.........does the constraint have to start and end with the "/"? and how that validates de period (like in mail.com) because if you don't have the format [email protected] it doesn't appear valid.

So I was hoping you guys could help understand the syntax, particularly because I need to forbid the entering of "<" and ">" in a textbox, and I know I can just do:
String s = textbox.getValue();
if(s.constains(">") || s.contains("<")){

}

Or something on the java end, but I would be a lot easier to include that constraint on the textbox in the zul.


Thank you so much in advance!

judacoor

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-01-24 22:30:12 +0800

judacoor gravatar image judacoor
280 1 3 8

updated 2009-01-24 22:32:31 +0800

Sorry for the typos....
and BTW, the constraint of the textbox is actually:

constraint="/.+@.+\.a-z+|/: Please enter.....

link publish delete flag offensive edit

answered 2009-01-24 22:32:06 +0800

judacoor gravatar image judacoor
280 1 3 8

updated 2009-01-24 22:33:25 +0800

There's a part missing....maybe it's because you're not supposed to use ] or [
They're supposed to be before the a and after the z.

Sorry..

link publish delete flag offensive edit

answered 2009-02-02 04:23:43 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2009-02-02 04:24:10 +0800

the constraint in textboxs that you mentioned, it follows the 'regular expression'.(I think just call the JAVA/JavaScript regular expression api to handle it.

if you want to write more custom constraint which isn't regular-able, you can write custom constraint.
http://docs.zkoss.org/wiki/Form_and_Inputs#Custom_Constraints

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2009-01-24 22:26:23 +0800

Seen: 826 times

Last updated: Feb 02 '09

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