JQuery Datepicker Will not post with UK date string

前端 未结 3 350
臣服心动
臣服心动 2021-01-13 11:40

Apologies for if the question is obvious but I can\'t figure out why it is suddenly not working. I have a jquery datepicker that has been working fine as long as I can remem

相关标签:
3条回答
  • 2021-01-13 12:07

    a google search gave a lot of results relating to localizing/globalizing asp.net mvc 3 validation.

    this article in particular might be on to something:

    http://www.hanselman.com/blog/GlobalizationInternationalizationAndLocalizationInASPNETMVC3JavaScriptAndJQueryPart1.aspx

    scroll down to: "Globalized jQuery Unobtrusive Validation"

    the answer to this question might help as well: Localizing jquery validation with asp.net mvc 3

    jQuery allows you to override the different validation functions like so:

     $.validator.methods.number = function (value, element) {
         return !isNaN($.parseFloat(value));
     }
    

    you could do something like this for the date validator, and run it against a regEx for a valid UK date.

    0 讨论(0)
  • 2021-01-13 12:17

    You can use the dateFormat, so in your javascript file (after the page is loaded etc.) you can place:

    $('.datepicker').datepicker({dateFormat:'yy-mm-dd'});
    
    0 讨论(0)
  • 2021-01-13 12:33

    Try using altFormat instead!

    altFormat: "dd/mm/yy",      
    

    That works for me : )

    EDIT: Try this on JSFiddle http://jsfiddle.net/adover/BRfcK/

    0 讨论(0)
提交回复
热议问题