struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Piker" <scott.pi...@xede.com>
Subject RE: time validation mask (hh:mm)
Date Thu, 10 Mar 2005 18:30:44 GMT
Quid pro quo for answering my CSS post... :-)

Just surround your pattern with start-of-line (^) and end-of-line ($)
chars and you should get the behavior you desire:

         <constant>
            <constant-name>time</constant-name>
	
<constant-value>^((?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9])$</constant-value
>
         </constant>

Incidentally, I came across this useful utility for regular expression
testing called the RegEx coach: http://www.weitz.de/regex-coach/
Doesn't teach you anything about regex, but it's a great debugging tool.

- Scott

-----Original Message-----
From: Matt Raible [mailto:lists@raibledesigns.com] 
Sent: Thursday, March 10, 2005 1:09 PM
To: Struts Users Mailing List
Subject: time validation mask (hh:mm)

I'm trying to validate that the proper format has been used to enter a
24 hour time.  I'll admit I'm not a regex expert, but I thought the
following would work.  Actually, I got it from a regex expert friend, so
I'm just assuming it should work.

         <constant>
             <constant-name>time</constant-name>
             
<constant-value>((?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9])</constant-value>
         </constant>

However, this seems to allow alpha-numerics (i.e. 2:00p or 2:00x), when
I only want digits in the first two places, followed by a colon,
followed by two more digits.  24:59.  If course, it'd be nice if users
could enter 1:24 too, but that's not a requirement.

Thanks,

Matt



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message