Domanda

<%@ 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>

In above page I'm getting alert but submission is not stopping, even I'm returning false. I'm getting no errors.

È stato utile?

Soluzione

Use it in the submit button, not in the form:

<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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top