Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to eformat the text box by using the comma(,) operator.
I need to create a project that is having a text box control that is to get the indian rupees as input.while the user is entering the input it should automatically format the input by adding the comma operator,that is ie. 1,00,000 for this input is 100000.the comma should be inserted automatically while the user entering the value in the text box.


will you please help me to get the answer ..........
Posted

Go to this link
http://www.integraxor.com/blog/number-formatter-is-now-localized
download numberformat.js . its simple plug in. supports multiple format of currency, very easy to use. We have been uses it our online retail project.

How to use it..
add .js to your website,

on blur of text field.
JavaScript
$('input[id$="totalAmount"]').val(format("###,###,###.##",amount.toFixed(2)));


on calculation of amount replace , and other separator.
JavaScript
var temp=($('input[id$="totalAmount"]').val()).replace(/\,/g,"");
 
Share this answer
 
use javascript

XML
<script type="text/javascript" language ="javascript">
 function Comma(nStr)
 {
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    return x1 + x2;
 }
</script>
 
Share this answer
 
I need to create a project that is having a text box control that is to get the indian rupees as input.while the user is entering the input it should automatically format the input by adding the comma operator,that is ie. 1,00,000 for this input is 100000.the comma should be inserted automatically while the user entering the value in the text box.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900