Several forms of form form submission in MVC
First Way: Submit button Submission
<form action= "Mydemand" method= "POST" > <span> keywords:</span> <input name= "keywords" type= "Text" value= "@keywords"/> <input type= "Submit" value= "search"/> </form>
The second way: $ ("#dataform"). Ajaxsubmit () Submit
<form id= "DataForm" action= "Updateuserinfo" enctype= "Multipart/form-data" method= "POST" > <table style= "width:100%;border:0;" cellpadding= "0" cellspacing= "0" > <tbody> <tr> <td width= "40" > Name:</td> <td><input type= "text" name= "Nvc_name" id= "Nvc_name" value= "@Model. Nvc_name"/> </td> </tr> <tr> <td colspan= "2" align= "center" > <input type= "button" Value= "Save" id= "Btnsubmit"/> </td> </tr> </tbody> </table> </form>
<script src= "Http://code.jquery.com/jquery-1.11.0.min.js" ></script><script src= "/http Malsup.github.io/jquery.form.js "></script>//ajaxform dependent script <script type=" Text/javascript "> $ ( Document). Ready (function () { $ ("#btnsubmit"). Click (function () {if ("[Name= ' Nvc_name ']"). val () = = "") { Alert ("Please fill in the name"); $ ("[name= ' Nvc_name ']"). focus (); return; } $ ("#dataform"). Ajaxsubmit (function (r) { alert (r.msg); if (r.success) { location.reload ();}})}) ; </script>
Third Way: Post submission
<table style= "width:100%;border:0px;" cellpadding= "0" cellspacing= "0" > <tbody> <tr> <td width= "15%" align= "right" > Mobile phone number:</td> <td><input type= "text" placeholder= "Please enter phone number" Id= "Nvc_user_name"/></td> </tr> <tr> <td colspan= "2" align= "Center" > <input type= "button" value= "Save" id= "Btnsubmit"/> </td> </tr> </tbody></ Table>
<script type= "Text/javascript" >$ (function () { $ ("#btnsubmit"). Click (function () { var nvc_user_name = document.getElementById (' Nvc_user_name '); $.post ('/interface/modefiypwd ', { nvc_user_name:nvc_user_name.value, }, function (data) { if ( data.success) { $ ("#successdiv"). Show (); $ ("#editdiv"). Hide (); } else { layer.msg (data. (MSG);});}) </script>
Fourth: Add the OnClick event validation form for the button in from and submit
<form method= "POST" action= "Recordedit" id= "DataForm" > <table width= "100%" border= "0" cellspacing= "0" cellpadding= "0" > <tr> <td align= "right" > App path:</td> <td> <input Type= "text" name= "Nvc_app_path" id= "Nvc_app_path" > </td> </tr> <tr class= "B_TR2" > <td><input type= "button" onclick= "Checkform ()" Value= "Save" ></td> </tr> </table></form>
<script src= "Http://libs.baidu.com/jquery/1.7.2/jquery.js" ></script><script src= "~/scripts/layer/ Layer.js "></script><script type=" text/javascript "> function Checkform () { if ($ (" # Nvc_app_path "). Val (). length = = 0) { layer.tips (" The application path cannot be empty "," #nvc_app_path "); return; } $ ("#dataForm"). Submit (); } </script> <br>