zimmer9
asked on
How would you modify the following validation expression in ASP.NET to allow for thousands separators and value must be > 0.00?
How would you modify the following validation expression in ASP.NET
^(\d){1,18}(\.\d{1,2})?$
to require a decimal point and ONLY 2 decimal places after the decimal point?
max value: 99,999,999,999,999.99
The value should be > 0.00
^(\d){1,18}(\.\d{1,2})?$
to require a decimal point and ONLY 2 decimal places after the decimal point?
max value: 99,999,999,999,999.99
The value should be > 0.00
^[0-9]{1,15}(\.[0-9]{1,2}) ?$
That is different than your original statement....
99,999,999,999,999.99
and you have 6.845.88
99,999,999,999,999.99
and you have 6.845.88
But you deleted what you posted LOL. Did the expression work for you?
ASKER
I deleted what I posted because I noticed that I had entered the value with 2 decimal points 6.845.88 as you had stated:
I re-input the value as 6,845.88 and I get the error message that I had set up:
ErrorMessage="Enter dollars, decimal, cents and commas. (ex: 0.36)."
I used the following code:
<td align="left" width="50%" style="font-family: Arial, Helvetica, sans-serif;
font-style: normal; font-weight: bold;color: #00356A; " class="style18"> Dollar Amount:
<asp:Label ID="Label4" Text = " " runat ="server" ForeColor="#00356A" Width="2%" />
<asp:TextBox ID="txtAmountS" Maxlength="21" runat="server"
style="margin-right: 0px" Width="25%" ></asp:TextBox>
<asp:RegularExpressionVali dator ID="RegularExpressionValid ator3" runat="server"
ErrorMessage="Enter dollars, decimal, cents and commas. (ex: 0.36)."
ControlToValidate="txtAmou ntS" ForeColor="#FF0066"
SetFocusOnError="true"
ValidationExpression="^[0- 9]{1,15}(\ .[0-9]{1,2 })?$">
</asp:RegularExpressionVal idator>
<asp:Label ID="lblHowMany" runat="server" Text="How Many" Visible="False"
Width="10%"></asp:Label>
<asp:TextBox ID="txtHowManyS" runat="server" Height="25px" Visible="False"
Width="12%"></asp:TextBox>
&n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp; &nbs p; &n bsp;
</td>
I re-input the value as 6,845.88 and I get the error message that I had set up:
ErrorMessage="Enter dollars, decimal, cents and commas. (ex: 0.36)."
I used the following code:
<td align="left" width="50%" style="font-family: Arial, Helvetica, sans-serif;
font-style: normal; font-weight: bold;color: #00356A; " class="style18"> Dollar Amount:
<asp:Label ID="Label4" Text = " " runat ="server" ForeColor="#00356A" Width="2%" />
<asp:TextBox ID="txtAmountS" Maxlength="21" runat="server"
style="margin-right: 0px" Width="25%" ></asp:TextBox>
<asp:RegularExpressionVali
ErrorMessage="Enter dollars, decimal, cents and commas. (ex: 0.36)."
ControlToValidate="txtAmou
SetFocusOnError="true"
ValidationExpression="^[0-
</asp:RegularExpressionVal
<asp:Label ID="lblHowMany" runat="server" Text="How Many" Visible="False"
Width="10%"></asp:Label>
<asp:TextBox ID="txtHowManyS" runat="server" Height="25px" Visible="False"
Width="12%"></asp:TextBox>
&n
</td>
^\d{0,15}(?:\.\d{0,2})?$
ASKER
^\d{0,15}(?:\.\d{0,2})?$
Would this accommodate the thousands separator (commas)?
It appears I get the same error when entering a value with commas.
Would this accommodate the thousands separator (commas)?
It appears I get the same error when entering a value with commas.
Here is another approach:
/^(?:0*[1-9]\d*\s*(?:,|$)\ s*)+$/gm
/^(?:0*[1-9]\d*\s*(?:,|$)\
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.