Amir wrote:
[color=blue]
> I'm looking for an example of form validation by JavaScript before it's
> processed by a PHP script.[/color]
This would be more on-topic in comp.lang.javas cript. Anyway...
What are you trying to validate? It's a little difficult to give you
anything useful unless that's known.
The basic format you should be looking at is:
<form ... onsubmit="retur n validate(this); ">
function validate(form) {var elem = form.elements;
/* ... */
}
where the controls within the form can be accessed through the elements
collection (referenced by elem for convenience, above), and the validate
function returns false if validation fails; true otherwise.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
where the controls within the form can be accessed through the elements collection (referenced by elem for convenience, above), and the validate function returns false if validation fails; true otherwise.
Mike
Thanks! This is exactly what I needed:
<form ... onsubmit="retur n validate(this); ">
I got the validation function, just couldn't figure out how to activate it before processing the form by a PHP script.
on 04/26/2005 03:38 PM Amir said the following:[color=blue]
> I'm looking for an example of form validation by JavaScript before it's
> processed by a PHP script.[/color]
You may want to take a look at this popular class for generating and
validating forms that can generate the necessary Javascript for you to
perform many kinds of common validation types on the client site. It can
also perform the same types of validation on the server side with class
PHP code itself.
Comment