Link to home
Start Free TrialLog in
Avatar of tbsolutions
tbsolutionsFlag for Brazil

asked on

Javascript Currency Money not working correctly

I have a javascript function that duplicate any number i press, for example:
I type: 1
It writes: 0,011 (instead of only 0,01)

The function works fine if i enable the "return false" in the end of the function, but the problem is that enabling it, it causes some functionality problems on my page.

 User generated image User generated image
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Maybe off topic but check this plugin : http://digitalbush.com/projects/masked-input-plugin/

test page :
<%@ Page Title="Page d'accueil" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<script language="javascript" type="text/javascript" src="http://cloud.github.com/downloads/digitalBush/jquery.maskedinput/jquery.maskedinput-1.3.min.js"></script>
<script language="javascript" type="text/javascript">

    $(document).ready(function () {
        $("#<%= txtValorStrike.ClientID %>").mask("9.999.999,99");
    });

</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:TextBox ID="txtValorStrike" CssClass="TextBoxCommon" runat="server" Width="134px" AutoPostBack="True" OnTextChanged="txtValorStrike_TextChanged"></asp:TextBox>
</asp:Content>

Open in new window

Avatar of tbsolutions

ASKER

Good solution leakim971, but the company doesn't accept jQuery plugins yet....
Thanks!
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You got it! I was about to give up...
Thank you very much!!!
You're welcome! Thanks for the points! Have a nice week!