Problem with STRUTS validator mask regexp

R

Roland

Hello,

I have the following problem when trying to use the validator. I have
a field
which should have an entry with the following pattern:

dddd.d+ (4 digits followed by a dot followed by 1 or more digits)

Optionally the field can be empty. Note that strings consisting only
of WHITESPACE are not accepted!

Ok, using the following link I tested two regular expressions that do
what I want:
http://jakarta.apache.org/oro/demo.html

Both of these work:
^(\A\Z)|(\d{4}\.\d+)$
^(^$)|(\d{4}\.\d+)$

Now, if I put either of them in my validation.xml file:

<constant-value>^(^$)|(\d{4}\.\d+)$</constant-value>
<constant-value>^(\A\Z)|(\d{4}\.\d+)$</constant-value>

It doesn't work as expected. It happens that strings consisting only
of whitespace are accepted!

So do you have any clues?

Thanks,

Roland
 
W

Wendy Smoak

Roland said:
Now, if I put either of them in my validation.xml file:
<constant-value>^(^$)|(\d{4}\.\d+)$</constant-value>
<constant-value>^(\A\Z)|(\d{4}\.\d+)$</constant-value>
It doesn't work as expected. It happens that strings consisting only
of whitespace are accepted!

Are you using 'required' in addition to 'mask'?
 
R

Roland

Wendy Smoak said:
Are you using 'required' in addition to 'mask'?

No, I'm not using 'required'. The field is not required. There are two
possible entries that are correct:
1. Either the field is empty
2. Or the field has a number in the format dddd.d+

Any other value in the field(including one or more whitespaces) should
lead to an error message.

Roland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,006
Latest member
LauraSkx64

Latest Threads

Top