onSubmit无法在struts2移动表单提交中使用

时间:2014-05-08 11:32:41

标签: html jsp jquery-mobile struts2 onsubmit

<%@ taglib prefix="s" uri="/struts-tags"%>
<link rel="stylesheet"  href="css/themes/default/jquery.mobile-1.2.0.css" />    
<link rel="stylesheet"  href="css/style.css" /> 
<script src="js/jquery.js"></script>
<script src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script src="js/jquery.mobile-1.2.0.js"></script>
<script src="js/common.js"></script>

<script>
$(document).bind('mobileinit',function(){
    $.mobile.selectmenu.prototype.options.nativeMenu = true;
    $.mobile.page.prototype.options.addBackBtn = true;
});
</script>

<s:form action="getVocabularyForm.action" name="getVocabulary" id="getVocabulary" method="post" onsubmit="return submitAdvice(this);">
 <s:label key="label.sectorName" for="sectors"/>
 <s:select onchange="updateIndProcesses(this.value)" headerKey="" headerValue="Select Sector" list="#session.sectors" name="sectors" id="sectors" listKey="name" listValue="name" />
 <s:label key="label.indProcess" for="indProcess"/>
 <select name="id" id="indProcess">
   <option value="">Select Industry Process</option>
 </select>
 <input type="submit" value="Submit the Page" data-theme="b" data-role="button"  data-inline="true"/>
</s:form>

<script>
    function submitAdvice(form){
      alert("Welcome 123");
      return false;
    }
</script>

在上面的页面中,我正在收到提醒,但提交并没有停止,即使我回复了错误。我没有错误。

1 个答案:

答案 0 :(得分:2)

在提交按钮中使用它,而不是以下列形式:

<input type = "submit" 
      value = "Submit the Page" 
 data-theme = "b" 
  data-role = "button"  
data-inline = "true" 
    onclick = "return submitConfirm();" />

<script>
    function submitConfirm(){
      return confirm("Should I proceed with the form submission ?");
    }
</script>