Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7432487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:27:55+00:00 2026-05-29T09:27:55+00:00

I try to use the jQuery Globalization plugin in order to fix the comma

  • 0

I try to use the jQuery Globalization plugin in order to fix the comma problem with jquery unobstructive client validation. However I tried many many solutions and there no good solution to fix this. I am on a non-English localization computer and this is important that my customers enter a decimal value like “123,66” and not “123.66”. ASP.NET validation tell me that the price must be a number! meh ? are you serious ? lol

I am getting this javascript error when I try to do the fix.

$.global is undefined

Here my code.

Layout.cshtml

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>

    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"> </script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/globalize.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/cultures/globalize.cultures.js")" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery.form.js")"type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/glob.fix.js")" type="text/javascript"></script>
</head>

<body>
    @RenderBody()
</body>
</html>

glob.fix.js

$.validator.methods.range = function (value, element, param) {
   var globalizedValue = value.replace(",", ".");
   return this.optional(element) || (globalizedValue >= param[0] && globalizedValue <= param[1]);
}

$.validator.methods.number = function (value, element) {
   return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value);
}

I can’t understand.. it should work since I added ~/Scripts/globalize.js.

Any idea? or you might have a better solution for having client validation work and lets me enter comma as decimal values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:27:56+00:00Added an answer on May 29, 2026 at 9:27 am

    I found the way to finally get rid of the decimal problem with comma seperator!

    Here a picture of the result! No more validation problems.

    enter image description here

    The steps to the fix.

    1- Get the Globalization library for jQuery

    You must get the latest script! Also I found some answers out there that was outdated.
    The object to call the library is no more $.global or anything like that but Globalize.

    2- Include the scripts in your project. You must add them after jquery.validation stuff.

    <script src="@Url.Content("~/Scripts/globalize.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/cultures/globalize.cultures.js")" type="text/javascript"></script>
    

    3- Replace some methods of the validator. This will override the methods for ‘number’ and ‘range’ validation which was causing problems.

    $.validator.methods.number = function (value, element) {
        return this.optional(element) || !isNaN(Globalize.parseFloat(value));
    } 
    
    $.validator.methods.range = function (value, element, param) {
        return this.optional(element) || (Globalize.parseFloat(value) >= param[0] && Globalize.parseFloat(value) <= param[1]);
    }
    

    Globalize.parseFloat => This will actually replace anything that contains ‘,’ to ‘.’ if you selected a culture that require it.

    After this.. You must add. This will make the globalize functions to work with the culture.

    $(document).ready(function () {
            Globalize.culture('fr-CA');
    
            // Only there to show which culture are being used.
            console.log(Globalize.culture().name);
    });
    

    The complete code look like…

    <!DOCTYPE html>
    <html>
    <head>
        <title>@ViewBag.Title</title>
        <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    
        <script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"> </script>
        <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/globalize.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/cultures/globalize.cultures.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery.form.js")"type="text/javascript"></script>
    
    
    <script type="text/javascript">
    
        $.validator.methods.number = function (value, element) {
            return this.optional(element) || !isNaN(Globalize.parseFloat(value));
        } 
        $.validator.methods.range = function (value, element, param) {
            return this.optional(element) || (Globalize.parseFloat(value) >= param[0] && Globalize.parseFloat(value) <= param[1]);
        }
    
        $(document).ready(function () {
            Globalize.culture('fr-CA');
    
            // Only there to show which culture are being used.
            console.log(Globalize.culture().name);
        });
    </script>
    
    </head>
    
    <body>
        @RenderBody()
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i try to use this jQuery plugin : http://jscrollpane.kelvinluck.com but anyway can i scrolling
I try to use jQUery-UI autocomplete plugin with a list of inputs that have
i try to use Tag-it jquery plugin. it convert entry tag to: <input type=hidden
I try to use the SQL statement SELECT * FROM table ORDER BY column
i try to use jQuery.noConflict() but in window.load function i get a $ is
I'm trying to use the jQuery.url plugin ( http://projects.allmarkedup.com/jquery_url_parser/ ) to grab a specific
Hi I am starting to use jQuery and when I try to select the
When i use use following inline jQuery Based validation in asp.net c# web form
I use jquery 1.6.4 and I just try to get city corresponding to a
I am try to use jquery.min.js for a image slider on facebook fan page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.