2013-03-03 22 views
0
后不提交表单

我想设置的延迟,当用户点击表单提交,提交前..我有一个显示测试点击事件的图像,并能正常工作,但形式也从未提交....submit()setTimeout的

这里是我的HTML表单:

<form class='loginForm1' action='verify_credentials.php' method='post'> 
    <fieldset> 
     <legend>Log into Answer Tree</legend> 
     <label>Username</label> 
     <input class='inputs' name='username' type="text" placeholder="Enter username..."> 
     <label>Password</label> 
     <input class='inputs' name='password' type="text" placeholder="Enter password..."> 
     <label class="checkbox"> 
      <input type="checkbox">Remember me</label> 
     <button id='submit' type='button' class="btn btn-success">Submit</button> 
    </fieldset> 
</form> 

这里是脚本:

$(document).ready(function() { 
    $(".containerLogin img").hide(); 
}); 

$(function() { 
    $("#submit").click(function() { 
     $(".containerLogin img").show(); 
     setTimeout(submitForm, 1000); 
    }); 
}); 

function submitForm() { 
    $(".loginForm1").submit(); 
} 

我得到这个错误信息:

Uncaught TypeError: Property 'submit' of object #<HTMLFormElement> is not a function

+0

好,'.delay(2000)$(”。loginForm1' )'是一个错误的语法,和二,.delay()只延迟动画。您应该按照问题标题中的建议使用setTimeout。 – 2013-03-03 05:48:07

+0

您有两个开始'

'标记,并且fieldset应位于'
'内。 – 2013-03-03 05:52:14

+0

srry添加了错误的代码...这是我一直在 – 2013-03-03 05:52:35

回答

1

你必须与你按钮的命名问题,它覆盖了提交()处理。

重命名按钮

<button id='btnSubmit' type = 'button' ... 

,改变你的选择相匹配。

+0

哟,它做了大声笑谢谢接受作为答案时.. :) – 2013-03-03 05:56:57