I would like to inform you of this excellent fom validation implementation,
based on prototype, by Andrew Tetlaw:
http://tetlaw.id.au/view/javascript/really-easy-field-validation
>From his website:
"
The basic method is to attach to the form's onsubmit event, read out all the
form elements' classes and perform validation if required. If a field fails
validation, reveal field validation advice and prevent the form from
submitting.
Include the javascript libraries:
<script src="prototype.js" type="text/javascript"></script>
<script src="validation.js" type="text/javascript"></script>
You write elements like this:
<input class="required validate-number" id="field1" name="field1" />
passing the validation requirements in the class attribute.
You then activate validation by passing the form or form's id attribute like
this:
<script type="text/javascript">
new Validation('form-id'); // OR new Validation(document.forms[0]);
</script>
It has a number of tests built-in but is extensible to include your custom
validation checks.
The validator also avoids validating fields that are hidden or children of
elements hidden by the CSS property display:none. This way you can give a
field the class of 'required' but it's only validated if it is visible on
the form. The demo
<http://tetlaw.id.au/upload/dev/validation/valid.html>illustrates what
I am talking about
"
Cheers,
Alexandre
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---