Carolinat
asked on
How can I validate in a form an amount with two decimals like 12.98
Hi Guys,
Does any one have a function to validate a textbox with format like 99.99?
Also, if the value doesn't have cents or decimals as soon as the cursor leaves the textbox it should add .00 to the amount.
I'm working with ASP.
Thanks
Carol
Does any one have a function to validate a textbox with format like 99.99?
Also, if the value doesn't have cents or decimals as soon as the cursor leaves the textbox it should add .00 to the amount.
I'm working with ASP.
Thanks
Carol
use this javascript function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
then call it from onchange event of a textbox:
<input type="text" name="text1" onchange="this.value = FormatCurrency(this.value) ;">
<input type="text" name="text1" onchange="this.value = FormatCurrency(this.value)
ASKER
Hi YZlat,
I'm using a control for the textbox like this:
<asp:textbox id="txtValor1" runat="server">
How can I call the javascript function from here?
I'm using a control for the textbox like this:
<asp:textbox id="txtValor1" runat="server">
How can I call the javascript function from here?
txtValor1.Attributes.Add(" onchange", "javascript:this.value = FormatCurrency(this.value) ;")
place this code in Page_Load event
ASKER
Excellent!!!
Thank you.
Carol
Thank you.
Carol