Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,

I am stuck with a trivial problem. I want to format data entered by user into text boxes separated with comma.
Ex : 12,345.00 instead of 12345 . It should also contain the decimal part.
I tried with ajax masked edit extender but my client is not comfortable as it shows commas and dots while typing.
I am looking for easy client side formatting as I have many text boxes. Once user enters data , format should change as above. I am attaching my code using ajax extender though it may not help with my problem. Please help me. Thanks in advance :)

XML
<asp:TextBox
               ID="tbcommunications" runat="server"
               style="margin-left: 0px; margin-bottom: 0px;" Height="100%" Width="80%"  CssClass="style22" TabIndex="16" Font-Names="Trebuchet MS" Font-Size="Small"></asp:TextBox><asp:MaskedEditExtender ID="MaskedEditExtender14" runat="server" TargetControlID="tbcommunications"
   Mask="9,999,999.99"
   MessageValidatorTip="true"
   OnFocusCssClass="MaskedEditFocus"
   OnInvalidCssClass="MaskedEditError"
   MaskType="Number"
   InputDirection="RightToLeft"
   AcceptNegative="Left"
   DisplayMoney="Left"
   ErrorTooltipEnabled="True">
                                       </asp:MaskedEditExtender>
Posted

1 solution

Use FiletedTextExtender, It validates for money type. may fit for your requirement.

Its also ajax tool kit control

to use this you have to register ajax tool kit in page.

XML
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" FilterType="Numbers, Custom"
    ValidChars=".," TargetControlID="TextBox8" />
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900