alert()
工作正常,但return false
不停止表單被張貼 - 任何想法?JQuery手機 - 返回false不阻止表單提交
<script type="text/javascript">
function form_val() {
//Check date
var email=document.getElementById('email').value;
var passw=document.getElementById('password').value;
if(email==''||email==null||passw==''||passw==null) {
alert('Please fill in both fields.');
return false;
}
}
</script>
<form action="userlogin.html" method="post" name="log_form" onsubmit="return form_val();">
<div data-role="fieldcontain">
<input type="email" name="email" id="email" value="" placeholder="Email Address" />
<input type="password" name="password" id="password" value="" placeholder="Password" />
<div class="ui-grid-a">
<div class="ui-block-a">
<button type="submit" name="login" value="" data-theme="c">Sign In</button>
</div>
<div class="ui-block-b">
<br />
<a href="http://mobile.*****.com/lostpswd.html" rel="external" style="font-size:10px; padding-left:10px;">Forgotten Password?</a>
</div>
</div>
</form>
謝謝你的幫助,我學到了很多! –