I am developing a form with add more button. When I click the button, a set of field will be generated. I have done the javascript validation for this, if all the added field is empty alert the message. The code for that is:
var n = document.getElementById('cnnumrows').value, i;
if ( frm_add_announcement.sublink[1].checked == true ) {
for(i=1; i<=n; i++) {
if ( (document.getElementById('url'+i).value.trim()=="") && ( document.getElementById("document"+i).files.length == 0 ) ) {
alert("Enter a url/upload a file");
document.getElementById('captionurl').focus();
return false;
}
}
}
I have to change this to if any of the fields is inserted value no need to alert and if all is empty alert. Any suggestion