2016-08-07 5 views
0

클라이언트 쪽 유효성 검사를 만들려고합니다. 페이지의 필드를 비워두고 제출 버튼을 클릭하면 서버 측 유효성 검사가 작동하지만 클라이언트 측 유효성 검사가 작동하지 않습니다. 또한 layout.cshtml 파일에 jqueryval 번들을 포함합니다.클라이언트 쪽 유효성 검사가 작동하지 않습니다. asp.net mvc5

@Scripts.Render("~/bundles/jqueryval") 

또한 web.config 파일의 라인을 다음 체크 한

<add key="ClientValidationEnabled" value="true" /> 

모델 :

public class File 
{ 
    [Required] 
    public string Name { get; set; } 
    [Required] 
    public string Description { get; set; } 

    public DateTime DateCreated { get; set; } 
    public DateTime DateModified { get; set; } 
    [Required] 
    public string FileSrc { get; set; } 

} 

보기 :

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

    <div class="form-horizontal"> 
     <h4>File</h4> 
     <hr /> 
     @Html.ValidationSummary(false, "", new { @class = "text-danger" }) 
     <div class="form-group"> 
      @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" }) 
      <div class="col-md-10"> 
       @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } }) 
       @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" }) 
      </div> 
     </div> 

     <div class="form-group"> 
      @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" }) 
      <div class="col-md-10"> 
       @Html.TextAreaFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } }) 
       @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" }) 
      </div> 
     </div> 


     <div class="form-group"> 
      @Html.LabelFor(model => model.FileSrc, htmlAttributes: new { @class = "control-label col-md-2" }) 
      <div class="col-md-10"> 
       <input type="file" id="FU" multiple /> 
       @Html.HiddenFor(model => model.FileSrc,new { id="fm"}) 
       @Html.ValidationMessageFor(model => model.FileSrc, "", new { @class = "text-danger" }) 
      </div> 
     </div> 

     <div class="form-group"> 
      <div class="col-md-offset-2 col-md-10"> 
       <input type="submit" value="Create" class="btn btn-default" /> 
      </div> 
     </div> 
    </div> 
} 

AM I없는 anythi 응?

+0

이 모델과 뷰의 일부를 표시 JQuery와 눈에 거슬리지 스크립트를 첨부 (당신이 또한 포함이'jquery- {버전} .js') –

+0

은 '예'jquery- {버전}'의 .js는 – Alex

+0

포함 @StephenMuecke _Layout.cshtml 또는 실제보기? – Alex

답변

-2

너무

+0

번들 jqueryval에 포함될 필요가 없습니다. – Alex

관련 문제