creative creative - 3 months ago 10
Javascript Question

javascript Form submit not working in safari and works in all other browsers?

Validation is working fine in all the browsers except Safari.
It includes 3 sections (a,b,c). In safari A and c section working perfectly. But when I click on B section it shows the alert "enter no of images". My result is

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

Answer

See the code if(document.commentform2.rb.value=='wed_custom') will always give a true

Please replace this line to

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