我的代码HTML
<input type="radio" class="w3-radio" name="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil1;?>" oninput="this.className = ''"> <?php echo $row->pil2;?>
<input type="radio" class="w3-radio" name="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil2;?>" oninput="this.className = ''"> <?php echo $row->pil2;?>
<input type="radio" class="w3-radio" name="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil3;?>" oninput="this.className = ''"><?php echo $row->pil3;?>
<input type="radio" class="w3-radio" name="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil4;?>" oninput="this.className = ''"><?php echo $row->pil4;?>
<input type="radio" class="w3-radio" name="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil5;?>" oninput="this.className = ''"> <?php echo $row->pil5;?>我的Javascript验证
function validateForm() {
// This function deals with validation of the form fields
var x, y, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("*");
// A loop that checks every input field in the current tab:
for (i = 0; i < y.length; i++) {
// If a field is empty...
if (y[i].value == "" || !y[i].checked) {
// add an "invalid" class to the field:
y[i].className += " invalid";
// and set the current valid status to false
valid = false;
}
}
// If the valid status is true, mark the step as finished and valid:
if (valid) {
document.getElementsByClassName("step")[currentTab].className += " finish";
}
return valid; // return the valid status
}如何修复验证无线按钮的这个问题?
此代码可以验证输入类型文本,但不能验证类型单选...我想我在这段代码中的问题!y[i].checked请帮我解决它
这是镜像我的程序enter image description here
https://stackoverflow.com/questions/47804687
复制相似问题