Click here to Skip to main content
Sign Up to vote bad
good
See more: Javascript
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 18 Nov '12 - 17:16


3 solutions

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.
  Permalink  
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.
 $('input[id$="totalAmount"]').val(format("###,###,###.##",amount.toFixed(2))); 
 
on calculation of amount replace , and other separator.
var temp=($('input[id$="totalAmount"]').val()).replace(/\,/g,"");
  Permalink  
use javascript
 
<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>
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 586
1 Maciej Los 255
2 Slacker007 240
3 OriginalGriff 220
4 CPallini 210
0 Sergey Alexandrovich Kryukov 9,118
1 OriginalGriff 7,134
2 CPallini 3,803
3 Rohan Leuva 3,135
4 Maciej Los 2,558


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid