I have a form and unfortunately built it without the help of external libraries (which I am now cursing myself for not including). So my form validation isn’t just form.validate() or something similar, it’s going to have to be an archaic javascript method (time constraints means I cannot implement external libraries because it’d involve rebuilding the form).
All I want is to check all the fields have been filled in – no email validation or post-code validation etc.
I tried a simple version:
if((document.getElementById("fieldA").value != "") || (document.getElementById("fieldB").value != "")){
alert("form okay");
}else{
alert("form not okay");
}
but this doesn’t work. The alternative to this would be to nest 45 if statements detecting each field individually but this is tedious and unfeasible.
you can loop trough elements in the form with
like
dropdown:
radiobuttons:
thanks to external libraries we don’t need that to do ourselves these days😉