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

  • Home
  • SEARCH
  • 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 1037337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:50:27+00:00 2026-05-16T14:50:27+00:00

I am trying out some globalization in an asp.net mvc2 application but can’t get

  • 0

I am trying out some globalization in an asp.net mvc2 application but can’t get it to work fully. I am using the library http://github.com/nje/jquery-glob as a tool to display currency and dates etc according to user wishes. However something is bothering me a little. IU can’t get the client / server side validation to actually accept the globalization using jQuery. No matter what I try if I post back 40.00 everything works ok but if I post 40,00 it is accepted as 0 (not a valid .NET invariant decimal value). I tried to follow @haacked‘s guide

This is in global.asax for server side handling:

private void SetCulture(string currencySymbol)
{
    AjaxHelper.GlobalizationScriptPath = 
        http://ajax.microsoft.com/ajax/4.0/1/globalization/";

    var culturePref = "sv-SE";
    var request = HttpContext.Current.Request;

    if (request.UserLanguages == null)
        return;

    var lang = request.UserLanguages[0];
    if (lang != null) {
        try {
            Thread.CurrentThread.CurrentCulture =
                CultureInfo.CreateSpecificCulture(lang);
        }
        catch {
            Thread.CurrentThread.CurrentCulture = 
                new CultureInfo(culturePref);
        }
    }

    Thread.CurrentThread.CurrentUICulture = 
        Thread.CurrentThread.CurrentCulture;
}

Then on the client side I have included the following scripts:

<script src="/Scripts/jquery-1.4.2.js" type="text/javascript"></script>
<script src="/Scripts/jquery.glob.js" type="text/javascript"></script>
<script src="/Scripts/globinfo/jquery.glob.sv-SE.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $.culture = jQuery.cultures['sv-SE'];
        $.preferCulture('sv-SE');
    });
</script>
<script src="/Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.pack.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript"></script>
<script src="/Scripts/jquery.metadata.js" type="text/javascript"></script>

So far so good but it doesn’t do much. Don’t get me wrong I can still get away with using it on the client but nothing really happens on the server side. The below jQuery changes the format’s accordingly but when I post back 40,00 it becomes 0.00.

function globalizePage(culture) {
    // Set culture from select list
    $.preferCulture(culture);

    $("input[id$='Date']").val(function () {
        var dateString = $(this).val();
        var date = Date.parse(dateString);
        var dt = $.format(date, 'd', culture.name);
        return dt;
    });

    $("input[id$='Price']").val(function () {
        var price = $.parseInt($(this).val());
        var retVal = $.format(price, 'c', culture.name);
        return retVal;
    });
}

What do I need to do to make the above code work?

  • 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-16T14:50:27+00:00Added an answer on May 16, 2026 at 2:50 pm

    Problem solved, bacon saved or chicken fried. The reason this is happening is that jquery.validate and jquery.glob uses a function called “format” if validate is added after glob then the validate.format function is called which breaks globalization. On the other hand validate function. I don’t know javascript or jquery good enough to tell you any workarounds. I’ll just code the validation of the form manually and forget about the MicrosoftMVCjQueryValidation since that doesn’t do the validate plugin justice.

    <script src="https://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="https://ajax.microsoft.com/ajax/jQuery.Validate/1.7/jQuery.Validate.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.glob.js" type="text/javascript"></script>
    <script src="/Scripts/globinfo/jquery.glob.sv-SE.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.forms.js" type="text/javascript"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C# .NET 3.5 and WCF, I'm trying to write out some of the
I'm trying to find out some matrix multiplication/inversion benchmarks online. My C++ implementation can
I am trying to separate some asp logic out into a separate page. For
I'm trying out ASP.NET MVC routing and have of course stumbled across a problem.
Im trying out some iPhone scroll view tests, but when i load the view,
I'm trying out some MacOS programming and having some trouble understanding how bindings work
I'm trying out some dynamic web page background generation using lines and text. Take
I am trying to parse out some information from Google's geocoding API but I
I'm trying to figure out some C code so that I can port it
I have just started learning Erlang and am trying out some Project Euler problems

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.