表单验证在ie8或ie7中不起作用

Form validation not working in ie8 or 7

本文关键字:ie7 不起作用 ie8 验证 表单      更新时间:2023-09-26

嗨,基本上我似乎无法在ie8或更低版本中使用表单验证。不过,它在其他地方都很好用。

基本上是这样的:

function validateform() {
    if (document.getElementById('firstinput').value == '') {
        alert("Select start Date");
        document.getElementById('firstinput').focus();
        return false;
    }
    if (document.getElementById('secondinput').value == '') {
        alert("Select end Date");
        document.getElementById('secondinput').focus();
        return false;
    }
    if (document.getElementById('restriction').checked == false) {
        alert('Please select I have read and understand the above restrictions.');
        return false;
    }
    if (document.getElementById('termscondition').checked == false) {
        alert('Please select terms and condition..');
        return false;
    }
    if (document.getElementById('letters_code').value == '') {
        alert("Enter captcha code..");
        document.getElementById('letters_code').focus();
        return false;
    }
    return true;
}​

只是想知道是否有我看不到的明显错误:谢谢你提前提供的帮助。

编辑,因为我分阶段非常糟糕!

我遇到了一个名为submit的提交按钮的问题,它只在IE中失败,而在firefox/chrome中没有,如果你能确保这不是问题所在,那将有所帮助!

或者,更多的信息会有所帮助,因为发布的代码似乎没有任何问题