Before submitting Form validation Mvc Html.BeginForm way

1. The use what form enclosed area code submitted

    @using(Html.BeginForm("AddMemberBaseInfo", "MemberManagement",FormMethod.Post, new { enctype = "multipart/form-data" }))

    {

        <inputtype="submit" class="buttons1" style="margin:0auto;" value="保存"/>

     <inputtype="text" class="texts" name="txtMemberName" />

     }

2.js Code

    $(document).ready(function () {

            $('form').bind('submit',checkform);

        });

  

        function checkform() {

            alert ( " verification before submission ");

            return false;

        }

3. The controller as usual values

   public ActionResult AddMemberBaseInfo()

    {

          string memberName=Request.Form["txtMemberName"].ToString();

    }

Reproduced in: https: //my.oschina.net/dongri/blog/610918

Guess you like

Origin blog.csdn.net/weixin_34101229/article/details/91765946