Resolve Jquery DatePicker Javascript Buddisht Era Year

Coordinator
May 16, 2013 at 2:39 PM
Edited May 16, 2013 at 2:59 PM
File1: Scripts/jquery-ui-1.8.24.js

Around Line 83xx
    /* Generate the HTML for the current state of the date picker. */
    _generateHTML: function(inst) {
        var today = new Date();
        today = this._daylightSavingAdjust(
            new Date(today.getFullYear() __+ 543__, today.getMonth(), today.getDate())); // clear time
Around Line 86xx

    /* Find the day of the week of the first of a month. */
    _getFirstDayOfMonth: function (year, month) { 
        return new Date(year __- 543__, month, 1).getDay();
    },
Around Line 694x

    this._defaults = { // Global defaults for all the date picker instances
        showOn: 'focus', // 'focus' for popup on focus,
            // 'button' for trigger button, or 'both' for either
        showAnim: 'fadeIn', // Name of jQuery animation for popup
        showOptions: {}, // Options for enhanced animations
        __defaultDate: new Date().getDate() + '/' + (new Date().getMonth() + 1) + '/' + (new Date().getFullYear() + 543) , // Used when field is blank: actual date,
        __
File 2 : View file of your
Around bottom line
@section Scripts {
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")  
    @Scripts.Render("~/bundles/jquerydp")  --> depend on your bunddle, datepicker js
     
    <script type="text/javascript" >
         
        jQuery(function ($) {
            
            $(document).ready(function () {

                $("#CreateWhen").datepicker({
                    dateFormat: 'dd/mm/yy', 
                    dayNames: ['อาทิตย์', 'จันทร์', 'อังคาร', 'พุธ', 'พฤหัสบดี', 'ศุกร์', 'เสาร์'],
                    dayNamesMin: ['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'],
                    monthNames: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],
                    monthNamesShort: ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.'],
                     
                });
                 
            });
        });
        
    </script>

}
Around Line View Field Date
@Html.TextBoxFor(m=>m,

(Model.HasValue ? 
Model.Value.ToString("dd/MM/yyyy", new CultureInfo("th-TH")) : ""), 

new { style="width:100%" })
File3:_Layout.cshtml
<head>
    @Styles.Render("~/Content/themes/base/css")
How to resolve jquery validation as The field xxx must be date
File1: jquery.validate.js
Around line 1099
date: function (value, element) {
            // Expect format (2012-3-1)
            // Bd format (31-3-2556)
            var arrayBd = value.split("/");
            if (arrayBd.length === 3) {
                value = (arrayBd[2] - 543) + '-' + arrayBd[1] + '-' + arrayBd[0];
            }
            return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
        },