0

モデルで DataAnnotations を使用しており、JavaScript 検証は正常に機能していますが、検証が無効な場合は送信ボタンを無効にする必要があります。

ここに私が働こうとしているいくつかのサンプルコードがあります

<h2>
Index</h2>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>HomeModel</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <p>
            <input type="submit" value="Save" id="submit-button" />
        </p>
    </fieldset>
}<div>
@Html.ActionLink("Back to List", "Index")</div>@section Scripts {    @Scripts.Render("~/bundles/jqueryval")}
4

1 に答える 1

-1

あなたが使用することができます:

$("#myform").validate({
  success: function() {
    //here enable your button
  }
});
于 2013-06-18T14:44:46.053 に答える