-1

我有我的jQuery的日期驗證腳本問題,所以我安裝了jQuery全球化package.I'm到包很新的安裝包的,所以我不太清楚如何利用腳本。我試着做以下,但它仍然給了我這個錯誤。如何使用jQuery全球化包日期驗證

Enrollment

Globalization

一切都在腳本中views文件夾 Scripts

片段\用戶\ Create.cshtml

<% Html.EnableClientValidation(); %> 
    <% using (Html.BeginForm()) 
    { %> 
     <%: Html.ValidationSummary(false) %> 
     <%: Html.EditorForModel() %> 
     <p> <input type="submit" value="Create" /></p> 
      <% } %> 

    </fieldset> 
} 

瀏覽\用戶\ Create.cshtml

@model RecreationalServicesTicketingSystem.Models.User 

@{ 
    ViewBag.Title = "Create"; 
} 

<h2>Create</h2> 

@using (Html.BeginForm()) { 
    @Html.AntiForgeryToken() 
    @Html.ValidationSummary(true) 

    <fieldset> 
     <legend>User</legend> 

     <div class="editor-label"> 
      @Html.LabelFor(model => model.LastName) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.LastName) 
      @Html.ValidationMessageFor(model => model.LastName) 
     </div> 

     <div class="editor-label"> 
      @Html.LabelFor(model => model.FirstMidName) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.FirstMidName) 
      @Html.ValidationMessageFor(model => model.FirstMidName) 
     </div> 

     <div class="editor-label"> 
      @Html.LabelFor(model => model.EnrollmentDate) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.EnrollmentDate) 
      @Html.ValidationMessageFor(model => model.EnrollmentDate) 
     </div> 

    <% Html.EnableClientValidation(); %> 
    <% using (Html.BeginForm()) 
    { %> 
     <%: Html.ValidationSummary(false) %> 
     <%: Html.EditorForModel() %> 
     <p> <input type="submit" value="Create" /></p> 
      <% } %> 

    </fieldset> 
} 

<div> 
    @Html.ActionLink("Back to List", "Index") 
</div> 

@section Scripts { 
    @Scripts.Render("~/bundles/jqueryval") 
} 
+1

我建議你閱讀http://stackoverflow.com/questions/30917036/globalizing-date-time-format-in-mvc –

+1

感謝您的建議! – TykiMikk

回答

0

我只是需要加入EN-NZ進入這行代碼中的jQuery-UI-1.8.24.js發現日期驗證開始工作

$.extend(this._defaults, this.regional['']); 


$.extend(this._defaults, this.regional['en-NZ']); 
1

嘗試是這樣的

@Html.TextBoxFor(m => m.DT_Project_Start, "{0:dd/mm/yyyy}") 

,看看它是否工作