[thelist] Submitting two validation scripts

Christian Heilmann codepo8 at gmail.com
Mon Apr 2 10:11:41 CDT 2007

> This is probably an easy one.  I have two validation scripts for a
> page and I want to put them both in one form onSubmit tag.  What is
> the correct code?  I thought it was:
> onsubmit="return validateForm(this,arrFormValidation); && return
> ValidateFormDate();"
> but that isn't working.

Why would you need to run two validation scripts? If they were written
without being really unobtrusive they are _very_ likely to clash.

In any case you'd need a wrapper function to get them together.

onsubmit = "return metaval(this,arrFormValidation)"

function metaval(){
  var ret = true;
  if(!validateForm(this,arrFormValidation)){ret = false;}
  if(!ValidateFormDate()){ret = false;}
  return ret;

Of course the best option is to have the first validation script call
the other one but without knowing what you do that is hard to explain.

Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/

More information about the thelist mailing list