javascript表单提交不在safari中工作,并在所有其他浏览器中工作?

时间:2016-08-18 10:00:10

标签: javascript safari

验证在除Safari之外的所有浏览器中都能正常运行。 它包括3个部分(a,b,c)。在safari A和c部分工作完美。但是当我点击B部分时,它会显示警告"输入no of images"。我的结果是alert('Enter total no. of images');

function validate()
 {

    if(document.commentform2.rb.value=='wed_custom')
{
    if(document.commentform2.cull_onoffswitch.checked===true)
    {
        if(document.commentform2.cull_images.value=='')
        {

            alert('Enter Cull total images');
            document.commentform2.cull_images.focus();      
            return false;
        }
        if(document.commentform2.cull_max.value=='')
        {
            alert('Enter Maximum no. of images');
            document.commentform2.cull_max.focus();     
            return false;
        }
    }
    else if(document.commentform2.str_onoffswitch.checked===false)
    {
        if(document.commentform2.total_images_lr.value=='')
        {
            alert('Enter total no. of images');
            document.commentform2.total_images_lr.focus();      
            return false;
        }
    }

}
else {
 if(document.commentform2.no_images.value=='')
{
    alert('Enter Number of images');
    document.commentform2.no_images.focus();        
    return false;
}
}

return true;
 }

1 个答案:

答案 0 :(得分:0)

查看代码   if(document.commentform2.rb.value=='wed_custom')将始终提供true

请用

替换此行
if(document.getElementById('Id').getAttribute('checked') === 'checked')
相关问题