【发布时间】:2011-02-28 22:14:40
【问题描述】:
如何添加内联验证以确保必须选择单选输入
<script type="text/javascript">
function choosePage() {
if(document.getElementById('weightloss').form1_option1.checked) {
window.location.replace( "http://google.com/" );
}
if(document.getElementById('weightloss').form1_option2.checked) {
window.location.replace( "http://yahoo.com/" );
}
}
</script>
<form id="weightloss">
<input type="radio" id="form1_option1" name="weight-loss" value="5_day" class="plan">
<label for="form1_option1"> 5 Day - All Inclusive Price</label><br>
<input type="radio" id="form1_option2" name="weight-loss" value="7_day">
<label for="form1_option2"> 7 Day - All Inclusive Price</label><br>
<input type="button" value="Place Order" alt="Submit button" class="orange_btn" onclick="choosePage()">
</form>
【问题讨论】:
-
编辑后的帖子包含一个代码块,因此所有标签都显示出来了......
-
为什么不默认选择其中一台收音机?
标签: forms input jquery-validate validation