2012-06-22 169 views
0

我創建了一個View。在這我已經把2個Multisubmit按鈕「創建」和「取消」。MultiSubmitButton客戶端驗證

現在,取消點擊後,客戶端驗證即將進行。但我不想打電話給客戶驗證。

我寫了如下代碼,請檢查它。我不希望在點擊取消按鈕時執行驗證。

@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