Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2005

Tip: Looking for answers? Try searching our database.

Problem with STRUTS validator mask regexp

Thread view: 
Roland - 18 Mar 2005 23:44 GMT
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
Wendy Smoak - 19 Mar 2005 00:00 GMT
> 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'?

Signature

Wendy

Roland - 21 Mar 2005 21:36 GMT
> > Now, if I put either of them in my validation.xml file:
> > <constant-value>^(^$)|(\d{4}\.\d+)$</constant-value>
[quoted text clipped - 3 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.