4

In my class I have the property:

public virtual DateTime Date { get; set; }

Which renders "31/12/2012 12:00:00 AM" by default with the culture set to "en-CA" and "12/31/2012 12:00:00 AM" if the culture is "en-US".

The JQuery validation works fine in "en-US" but in "en-CA" complains about "The field Date must be a date".

I think the solution is using the JQuery Globalization library. I just don't know how to do it for this "General Date Long Time ("G") Format Specifier" ASP.Net renders. Any ideas?

The field Date must be a date

Juan Carlos Puerto
  • 2,632
  • 1
  • 26
  • 22

1 Answers1

0

The General Long time ("G") Format Specifier format specifier "represents a combination of the short date ("d") and long time ("T") patterns, separated by a space".

While there is not an equivelant format specifier (jQuery Globalize Date Formatting) the same format can be accomplished by (verbose for clarity):

var shortDate = $.format(@Model.Date, "d");  //Get the short date  ...M/d/yyyy
var longTime = $.format(@Model.Date, "T");  //Get the long time...h:mm:ss tt  
var date = shortDate + " " + longTime;  //concat the two together.
Gareth
  • 5,140
  • 5
  • 42
  • 73
jeuton
  • 543
  • 3
  • 7