You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <ja...@wendysmoak.com> on 2005/04/07 00:08:19 UTC

Validating an amount with commas allowed

I have a form with a required "amount".  The users like to enter things like
$50k which thoroughly confuses the system that tries to send a different
email if the amount is over or under $25,000.  I think I can make them stop
entering dollar signs and letters... but I don't think they'll part with the
commas.

Before I write a custom validator, am I missing something simple that would
allow me to accept "40,000" as a valid amount?  The only thing I see is
integer validation, which is too strict.

Thanks,
-- 
Wendy Smoak


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


Re: Validating an amount with commas allowed

Posted by Hubert Rabago <hr...@gmail.com>.
I'm useless with regex.  However, I found this on the web some time
ago and seemed to match what I needed back then:

<var>
    <var-name>mask</var-name>
    <var-value>^(?:\d+|\d{1,3}(?:,\d{3})*)(?:\.\d{1,2}){0,1}$</var-value>
</var>

This allows them to include the ".00" if they so desire.

hth,
Hubert

On Apr 6, 2005 5:08 PM, Wendy Smoak <ja...@wendysmoak.com> wrote:
> I have a form with a required "amount".  The users like to enter things like
> $50k which thoroughly confuses the system that tries to send a different
> email if the amount is over or under $25,000.  I think I can make them stop
> entering dollar signs and letters... but I don't think they'll part with the
> commas.
> 
> Before I write a custom validator, am I missing something simple that would
> allow me to accept "40,000" as a valid amount?  The only thing I see is
> integer validation, which is too strict.
> 
> Thanks,
> --
> Wendy Smoak
> 
> ---------------------------------------------------------------------
> 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