Click here to Skip to main content
11,496,146 members (812 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
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 18:16pm
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  
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  

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

  Print Answers RSS
0 RyanDev 230
1 Sergey Alexandrovich Kryukov 114
2 Richard Deeming 100
3 OriginalGriff 89
4 Mostafa Asaduzzaman 59
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100