2012-06-22 2 views
0

하나의보기를 만들었습니다. 그 안에 "만들기"및 "취소"2 Multisubmit 단추를 넣었습니다.MultiSubmitButton Clientside 유효성 확인

이제 취소를 클릭하면 클라이언트 측 유효성 검사가 호출됩니다. 하지만 나는 고객 측 검증을 호출하고 싶지 않습니다.

아래 코드를 작성했습니다. 확인해주십시오. 취소 단추 클릭시 유효성 검사를 실행하지 않으려합니다.

@model Blog.Models.User 
@{ 
    ViewBag.Title = "Register New User"; 
} 

@using Microsoft.Web.Mvc; 
@using MVC3MultiSubmitButtonExtension; 
<h2> 
    Register New User</h2> 
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> 
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> 
@using (Html.BeginForm()) 
{ 
    @Html.ValidationSummary(true) 
    <fieldset> 
     <legend>Fill User Details</legend> 
     <div class="editor-label"> 
      @Html.LabelFor(model => model.FirstName) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.FirstName) 
      @Html.ValidationMessageFor(model => model.FirstName) 
     </div> 
     <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.Username) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.Username) 
      @Html.ValidationMessageFor(model => model.Username) 
     </div> 
     <div class="editor-label"> 
      @Html.LabelFor(model => model.Password) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.Password) 
      @Html.ValidationMessageFor(model => model.Password) 
     </div> 
     <div class="editor-label"> 
      @Html.LabelFor(model => model.EmailAddress) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.EmailAddress) 
      @Html.ValidationMessageFor(model => model.EmailAddress) 
     </div> 
     <div class="editor-label"> 
      @Html.LabelFor(model => model.MobileNumber) 
     </div> 
     <div class="editor-field"> 
      @Html.EditorFor(model => model.MobileNumber) 
      @Html.ValidationMessageFor(model => model.MobileNumber) 
     </div> 
     <p> 
      @* <input type="submit" value="Create" />*@ 
      @Html.MultiSubmitButton(Url.Action("Create"), "btnCreate", "Create") 
      @Html.MultiSubmitButton(Url.Action("Cancel"), "btnCancel", "Cancel") 
     </p> 
    </fieldset> 
} 
<div> 
    @Html.ActionLink("Click here to go Login Page", "Index") 
</div> 

답변

0

당신이 당신의 제출 취소 버튼 class="cancel"을 할당하는 경우, 클라이언트 측 유효성 검사가 실행되지 않습니다. 이 클래스를 할당하는 방법은 ASP.NET MVC에 속하지 않은 일부 사용자 도우미 Html.MultiSubmitButton을 사용하는 것처럼 말할 수있는 것이 아닙니다. 따라서 문서를 확인해야합니다.

+0

예 .. 작동합니다. 그러나 예를 들어 명확하게 특정 htmlvalidator 값을 지우고 싶습니다. EmailAddress HTML 편집기의 경우 텍스트를 지우고 싶습니다. – Nik