i am using NumberFormmater to format a number i have included a js file and wrote a simple code but it is not working. i am following this link /.
$('#txtNumber').formatNumber({format:"#,###.00", locale:"us"});
i am using NumberFormmater to format a number i have included a js file and wrote a simple code but it is not working. i am following this link http://code.google./p/jquery-numberformatter/.
$('#txtNumber').formatNumber({format:"#,###.00", locale:"us"});
Share
Improve this question
edited Jan 4, 2012 at 13:00
JN_newbie
asked Jan 4, 2012 at 12:46
JN_newbieJN_newbie
6,10216 gold badges69 silver badges105 bronze badges
0
2 Answers
Reset to default 6locale:"en" has an issue as per a link provided by you there is no locale like "en" if you want to do it for United States then try "us"
as well as no function like format
try
.formatNumber({format:"#,###.00", locale:"us"});
EDIT
$("#txtNumber").blur(function(){
$(this).parseNumber({format:"#,###.00", locale:"us"});
$(this).formatNumber({format:"#,###.00", locale:"us"});
});
have you written code like it?
you also need to add libraries first download all js then include it as follow:
<script type="text/javascript" src="jquery-min.js"></script>
<script type="text/javascript" src="jshashtable.js"></script>
<script type="text/javascript" src="jquery.numberformatter-1.2.2.min.js"></script>
As far as I can tell from the plugin page you linked, there is no format
function offered by the plugin. There are parseNumber
and formatNumber
. Both are available on jQuery instances (they use/set the val()
of the element), or as members of the jQuery
object itself (you pass them the data to use and receive the result as a return value). All of this is quite clearly laid out on that page.
Also note that the plugin requires jshashtable, perhaps you aren't including it?
And see also Hemant's note that there is no "en" locale listed as supported. You may want "us", "gb", "au", or...