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
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
Couldn't you simply format the display variable as "$"+mynumber.toFixed(2), and post mynumber.
ASKER
its a textbox, its not a label. the formatting needs to be done as you type.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
Try entering 123.45 and you should see $123.45 in your input box and 123.45 as the submitted value.
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.