Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:16pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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 Gihan Liyanage 392
1 ClimerChinna 247
2 Sergey Alexandrovich Kryukov 225
3 vikinghunter 176
4 OriginalGriff 161
0 Sergey Alexandrovich Kryukov 8,373
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,025
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2014
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