Jquery/js submit()無法提交問題

來源:互聯網
上載者:User

標籤:style   class   code   c   tar   ext   

有朋友可能會直接利用js或jquery來提交資料而不是使用表單直接提交了,小編來給大家介紹小編碰到的一個問題就是 submit()無法提交,下面我們來看解決辦法與原因分析。

jquery無法提交

 代碼如下 複製代碼

<form action="register.php" method="post">

<label>郵箱:</label> 
<input type="text" class="loginform_input" id="email" name="email" /><div id="emailerror"></div>


<input type="button" class="loginform_submit" id="submit" value="註冊" />

</form>

<script>

$("#submit").click(function() { 
$("form").submit(); 
});

</script>

當我提交時發現發無法正常提交,後來利用ff瀏覽器檢查錯誤時發現我們有一個id="submit",這樣解決辦法就出來了我們把

 代碼如下 複製代碼


<input type="button" class="loginform_submit" id="submit" value="註冊" />

改為

<input type="button" class="loginform_submit" id="register" value="註冊" />

再來提交就可以提交註冊了,下面來介紹有一朋友利用js也碰以相同的問題

,需要使用js提交form表單。發現使用document.form1.submit();方法無法提交表單。Firefox提示 submit is not a function 。最後找到解決方案。

1.表單中不能有name="submit" 的標籤 ----我的就是這個問題

2

 代碼如下 複製代碼
.<form action="expat_search.php" name="expat_search" id="expat_search" method="post" enctype="multipart/form-data">,

表單中不能缺少《enctype="multipart/form-data"》。

3.當使用js 進行FORM 表單驗證時:js驗證指令碼可以放在兩個地方    1) 放在form 頭標籤中。 
    2)放在

 代碼如下 複製代碼
<input type=‘submit‘  onsubmit=‘js_code()‘ />

,   3)放在

 代碼如下 複製代碼
<input type=‘buttom‘ onclick=‘js_code()‘ />

這裡總結下如果使用2)或者3)標籤方式。一定 submit =>‘onsubmit‘, buttom=>‘onclick‘ 成對使用不可以錯換。 如<input type=‘submit‘ onclick=‘js_code()‘/>這樣是錯誤的。

 

原文地址: http://www.php100.com/html/program/jquery/2013/0905/5935.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.