Localizing jquery validation with asp.net mvc 3

前端 未结 3 1326
野的像风
野的像风 2020-12-23 10:30

I am using Asp.Net Mvc3 and the unobtrusive jquery validation. I\'d like to have my dates validation localized, I mean, jquery is validating my date as being MM/dd/yyyy but

3条回答
  •  情话喂你
    2020-12-23 11:09

    If you are doing any work with internationalization and ASP.NET MVC I highly recommend reading through these two excellent posts by Nadeem Afana

    • ASP.NET MVC 3 Internationalization
    • ASP.NET MVC 3 Internationalization - Part 2 (NerdDinner Demo)

    In his second post he has a detailed example of using the jQuery UI datepicker and discusses the issues with localization.

    In his example he mentions the following

    @* Unfortunately, the datepicker only supports Neutral cultures, so we need to adjust date and time format to the specific culture *@
        $("#EventDate").change(function(){
          $(this).val(Globalize.format($(this).datetimepicker('getDate'), Globalize.culture().calendar.patterns.d + " " + Globalize.culture().calendar.patterns.t)); /*d t*/
        });
    

    i also recommend downloading the Nerd Dinner internationalization demo linked on his site.

提交回复
热议问题