I have a page that has 6 forms that all have a value with the same name ‘audit_id_upload’. Currently I have one of them being validated (I’m just looking for empty values) with…
function validateForm()
{
var x=document.forms["audit_upload"]["audit_id_upload"].value;
if (x==null || x=="")
{
alert("Please Select an Audit");
return false;
}
}
</script>
Can I adapt this to validate the other forms as well without having to repeat it 5 more times?
Thanks
Since you have a input element with
audit_id_uploadin every form, you could pass the name of your form to this function and use it to validate the item.and call it on the for onSubmit event.