ProtoFormClass is a Prototype class that allows you to very easily validate the forms fields and send data in ajax: you can view the source code here. I have rewritten the code of the old script to make it more object-oriented greatly simplifying deployment.
Implementations
ProtoformClass utilise the field elements id attribute to indicate the validation requirements (through prefixes).
The title attribute of the form fields (to be valitated) is used to show an error message; assign an id to each of these fields with your prefix and the type of validation desired.
If You want, customize form stylesheets, loading, errors and response message (ul#error, div#response, p#working, displayed with dhtml).
Event.observe(window,"load",function() {
new Protoform('myform', { ajax:false });
$$("form.myotherforms").each(function(forms){
new Protoform(forms);
});
});
Options
Class options:
Validation options (field elements id attribute prefix):
- _Req: required field
- _Email: validate yourmail@domain.ext
- _Tel: validate telephone number
- _Num: validate number (allowed decimal and sign" +", "-", ".")
- _Date: validate date (dd/mm/yy)
- _Url: validate http, https, ftp address
Download
Get ProtoFormClass (18/03/2009) - the package contains an working example and Prototype 1.6.0.3 library.
ProtoFormClass is licensed under the MIT license.
Suggestions
You can post your comments, suggestions or bug reports on my blog: I'm happy to receive aid to improve the script.