【问题标题】:javascript Form submit not working in safari and works in all other browsers?javascript 表单提交在 safari 中不起作用并且在所有其他浏览器中起作用?
【发布时间】:2016-08-24 23:14:18
【问题描述】:

验证在除 Safari 之外的所有浏览器中都能正常工作。 它包括 3 个部分(a、b、c)。在 safari A 和 c 部分工作完美。但是当我点击 B 部分时,它会显示警报“输入图像数量”。我的结果是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;
 }

【问题讨论】:

    标签: javascript safari


    【解决方案1】:

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

    请将此行替换为

    if(document.getElementById('Id').getAttribute('checked') === 'checked')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-03
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多