我正在使用Twitter bootrap的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>
为什么不按钮点击重新定位?