Link to home
Start Free TrialLog in
Avatar of genius_geek
genius_geek

asked on

input field formatting

Hi,

I have a input text box. It accepts number. This input field is submitted to the next page using POST.

What i want to do :
1. format the input field to currency format
2. but while POST-ing the field to next page, only the numeric value of the field should get posted.

Example:
Case 1: Text input field (without formatting)
2500
after post 2500

Case 2: (Desired case) Text input field
$ 2,500.00
after post 2500
Avatar of Amick
Amick
Flag of United States of America image

Couldn't you simply format the display variable as "$"+mynumber.toFixed(2), and post mynumber.
Avatar of genius_geek
genius_geek

ASKER

its a textbox, its not a label. the formatting needs to be done as you type.
ASKER CERTIFIED SOLUTION
Avatar of Amick
Amick
Flag of United States of America 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
http://jsfiddle.net/jfCGD/1/ decimals and commas do not work.
Decimals do work, but you are correct that commas don't as no comma logic has been provided.
Try entering 123.45 and you should see $123.45 in your input box and 123.45 as the submitted value.
User generated image
The purpose of the example code was simply to illustrate the first response by showing a way to use formatted input in the input box while submitting an unformatted value.