$(function () { $("#btn").click(function () { var usercode = $("#UserCode").val(); var verifycode = $("#Verifycode").val(); if ($.trim(usercode) == "" || $.trim(verifycode) == "") { alert(" 您的[客户号]或者[验证码]必须填写!"); return false; } else { document.SearchForm.action = '/index/Search?u=' + usercode; document.SearchForm.submit(); } }); });
<form id="SearchForm" name="SearchForm" method="post"> …… </form>
好处是:既想使用post提交表单,又想传递你想传递的某一个参数!