2016-08-07 7 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 ng?

+0

は、モデルとビューのいくつかを表示する(そしてあなたも 'jquery- {バージョン} .js'含まれている) –

+0

はい' jquery- {バージョン} 'の.jsが – Alex

+0

を含むが、あまりにもjqueryの控えめなスクリプトを添付します@StephenMuecke _Layout.cshtmlまたは実際のビュー? – Alex

答えて

-2

+0

バンドルjqueryvalに含まれている必要はありません – Alex

関連する問題