2012-05-31 26 views
0

我知道如何加載一個對話框<a href="alert.html" data-rel="dialog">test</a>我想要做的是有對話框加載,如果任何表單值是空白的。當點擊下一個(page15.html)鏈接時,這將被觸發/檢查。有關如何完成此任何建議?jQuery Mobile的:如果inputbox(s)是空的加載對話框

<a data-role="button" href="page15.html" data-icon="arrow-r" data-iconpos="right"> 
    Next 
</a> 
    <form action="#" method="POST"> 
     <div data-role="fieldcontain" class="no-field-separator"> 
      <fieldset data-role="controlgroup"> 
       <label for="textinput2"> 
        <span class="c_404040 f_bold">Body Fat Measurements</span> 
       </label> 
       <input id="textinput2" placeholder="Subsc (mm)" value="" type="number" /> 
      <br /> 
       <label for="textinput3"> 
       </label> 
       <input id="textinput3" placeholder="Supra Crest (mm)" value="" type="number" /> 
      <br /> 
       <label for="textinput4"> 
       </label> 
       <input id="textinput4" placeholder="Bic (mm)" value="" type="number" /> 
      <br /> 
       <label for="textinput5"> 
       </label> 
       <input id="textinput5" placeholder="Tri (mm)" value="" type="number" /> 
      </fieldset> 
     </div> 
    </form> 

回答

0

像這樣的事情會是一個方法:

var missingBox = 0; 
$('a[href="page15.html"]').click(function(e) { 
    e.preventDefault(); 
    $.each($('form input'),function() { 
     if($(this).val() == 0) { 
      missingBox += 1; 
     } else { 
     } 
    }); 
     if(missingBox > 0) { 
     console.log('alert'); 
    } 
}); 
+1