click函数在执行后提交表单

时间:2015-11-03 03:30:34

标签: jquery form-submit submit-button

在下面的代码中,点击go按钮后,表单应首先提交,然后验证应该进行。但表单是在执行完整的#go.click函数后提交的。

$('#go').click(function()  {
        $('form[name=dataExport]').submit();
         var distIdEntry = $.trim($("input[name='distID']").val());
       var getUrlParameter = function getUrlParameter(sParam) {
            var sPageURL = decodeURIComponent(window.location.search.substring(1)),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;

            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');

                if (sParameterName[0] === sParam) {
                    return sParameterName[1] === undefined ? true : sParameterName[1];
                }
            }
        };




          var districtID =getUrlParameter('distwpid');;

          if (distIdEntry.length === 0)
          {

          }


          //if input doesn't equal our district ID
          else if (distIdEntry !== districtID)
          {

          }
          //if input = our district ID
    else if (distIdEntry === districtID)
              {
               }
          return true;         
   });//End GO function

1 个答案:

答案 0 :(得分:0)

将验证码放在提交功能中:

$("#go").click(function(){
    $('form[name=dataExport]').submit(function() {
        // validation code
    });
});