我正在为 twitter bootsrap 使用 Nod 前端验证 - http://casperin.github.com/nod/
现在验证效果很好,但是当我在我的按钮上放置一个 onclick 函数以重新定位时,它不起作用(不会带我到新的 href :)
<div id="join" class="span12">
<label for="joinUsername">Username</label>
<input type="text" id="joinUsername" name="username" />
<br />
<label for="joinPassword">Password</label>
<input type="password" id="joinPassword" name="password" />
<br />
<label for="confirmPassword">Confirm Password</label>
<input type="password" id="confirmPassword" name="confirmPassword" />
<br />
<label for="email">Email (optional)</label>
<input type="text" id="email" name="email" />
<br /><br />
<input type="submit" class="btn btn-primary" onclick="location.href='subscribe.aspx';" value="Join now" />
</div>
这个:
onclick="location.href='subscribe.aspx';"
仅在未填写表格时有效,但是当我填写表格时,它根本不会重新定位...
JS:
<script type="text/javascript">
// A list of all the fields we wish to validate
var a_metrics = [
['#joinUsername', 'presence', 'Please enter a username'],
['#joinPassword', 'min-length:4', 'At least 4 characters please'],
['#confirmPassword', 'same-as:#joinPassword', 'Passwords do not match'],
['#email','email','Please enter a valid email address']
];
$('#form1').nod(a_metrics);
</script>
为什么它没有在按钮单击时重新定位?