1

I have a ASP.Net Web Form TextBox Control that I am able to change its text format formula to the currency formula but this happens after the user enter the number and causing a postback by method OnTextChanged() , but I need this to happen at real time.

Meaning: I need this to happen while user is writing without Postback? So should I write an extension method for this?

<asp:TextBox ClientIDMode="AutoID" onkeypress="CheckValueEntered(event);" runat="server" AutoPostBack="true" Text="0" OnTextChanged="plusEnteredAmount" ID="txtAmount" placeholder="المبلغ" CssClass="form-control a"></asp:TextBox>

and below I am changing the text formula on code behind

 txtAmount.Text = enteredAmount.ToString("#,##0", CultureInfo.InvariantCulture);
Ram Anugandula
  • 582
  • 4
  • 15
Khalid
  • 343
  • 3
  • 16
  • You should do server-side validation encase JavaScript is disabled. To validate it before postback use JavaScript on the client-side. – Jeremy Thompson Sep 20 '19 at 09:26

1 Answers1

1

You need to look at jQuery plugin for masking.

https://www.jqueryscript.net/other/Auto-Format-Currency-With-jQuery.html

here is demo

https://www.jqueryscript.net/demo/Auto-Format-Currency-With-jQuery/

Imad
  • 7,126
  • 12
  • 55
  • 112