Currency JavaScript

Posted on 2006-05-12
Last Modified: 2011-10-03

I have one AJAX application. As you all know, AJAX will send ansynchronous request to the server so that it does not need to refresh the page. However, I have one problem. As I send the values back to my JSP page, I want the value in textbox to be formatted to currency so that 20.7773 becomes €20.78.

Well, I can find many function freely available to do that. However, after the value is converted and formatted, I change the value in textbox again and the value is sent back to the server. It reports that it is not valid number as it contains €

Can you all suggest me the best way to tackle this problem?

Question by:suprapto45
    LVL 7

    Assisted Solution

    remove the € on submit
    or use a hidden field to pass the value without &euro, use this field value after submit.
    LVL 13

    Accepted Solution

    Hi suprapto45,

    I don't think it's a good idea to add the € in the textbox.
    You may instead put &euro; in front of the textbox like:  &euro; <input ...

    LVL 16

    Author Comment

    I will agree to Webstorm in this case. So both of you are providing valid answer.

    LVL 13

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Hire Freelancers to Complete JavaScript Projects

    Source the talented Expert Exchange community
    for top quality work on your JavaScript projects.

    Hire the best. Collaborate easily. Get quality work.

    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now