PDA

View Full Version : Looping through form fields to validate



wkenny
03-05-2010, 11:57 AM
I have the following code



if(killhttp(document.regform.website.value))
{errormessage += "\n\nInvalid website - do not use http:";}

if(killhttp(document.regform.link.value))
{errormessage += "\n\nInvalid web link - do not use http:";}

if(killhttp(document.regform.logo.value))
{errormessage += "\n\nInvalid logo location - do not use http:";}


which is a simple spam trap. I now have a much bigger form and want to know how would I rewrite the above so that all fields on the form could be checked (and exit from loop if function killhttp returns true).