I am using jQuery Globalize plugin along with jQuery validation.
For the valid swedish number 5.000,00 parseFloat function gives NaN
What could be the bug in below code/library?
<script type="text/javascript" src="/Scripts/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="/Scripts/globalize.js"></script>
<script type="text/javascript" src="/Scripts/cultures/globalize.culture.sv.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.unobtrusive.js" ></script>
<script type="text/javascript">
jQuery(function () {
Globalize.culture('sv');
$.validator.methods.number = function (value, element) {
if (Globalize.parseFloat(value)) { // this gives NaN
return true;
}
return false;
}
});
</script>
I think that you are using wrong culture. Or your input number is just in wrong format. http://jsfiddle.net/98sgm/1/
And source code from culture file:
EDIT: Create new culture file and set numberFormat options to following: