2016-08-18 76 views
2

在除Safari之外的所有瀏覽器中,驗證都正常工作。它包括3個部分(a,b,c)。在safari A和c部分完美運行。但是當我點擊B部分時,它顯示警報「輸入圖像的數量」。我的結果是alert('Enter total no. of images');javascript表單提交不在safari中工作,並在所有其他瀏覽器中工作?

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; 
} 

回答

0

看到代碼 if(document.commentform2.rb.value=='wed_custom')總是會給一個true

請更換

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

thanksssss ....其工作這一行... –

+0

@creative聽起來不錯:) – Jyothu

相關問題