Tom de Neef wrote:
"Olivia Towery" <ti*****@adelphia.netwrote
>I cannot figure out how to complete two script validations onsubmit. Only
the first one listed runs. If anyone knows how to do this, please help.
onsubmit=validate1(),validate2()
or
onsubmit=validate1()&&validate2()
This is _not_ the proper way as validation will be performed but form
submission will take place even if validation fails.
Furthermore, in both cases the attribute value would have to be quoted, due
to the characters `(', `)', `,', and `&' in it:
http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
Should be:
<form action="..." ...
onsubmit="return validate1(this) && validate2(this)">
If either validation fails, it should return `false' so that the boolean
expression evaluates to `false', which is returned to the event handler and
causes the form not to be submitted.
Another way that is a little bit easier to maintain:
function validate(f)
{
return validate1(f) && validate2(f);
}
<form action="..." ... onsubmit="return validate(this)">
Passing the `this' value saves one from having to look up the form object
reference in either validation method again.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann