FYI, client side form validator

0 views
Skip to first unread message

gasolin

unread,
Jun 24, 2006, 6:47:34 AM6/24/06
to TurboGears
FYI, There's a prototype(a js library) based form validaton library

http://tetlaw.id.au/view/blog/really-easy-field-validation-with-prototype

It''s light (8k, plus prototype lib(54k)), and the usage is pretty
straight forward.

ex:
{{{<!-- a form "testform" with a field "testfield" -->
<form id="testform" action="#" method="get">
<!-- passing the validation requirements in the class attribute.-->
<input name="testfield" class="required validate-alphanum" title="Enter
your employee number, please use only alphanumeric characters" />
</form>

<!-- activate validation by passing the form or form's id attribute -->
<script type="text/javascript">
var valid3 = new Validation('testform');
</script>
}}}

class attribute "required validate-alphanum" tell client the field is
required and will be validate by alphanum.

To add on-form error notifiers is easy, just include a css to specify
the following style:
- input.required
- input.validation-failed
- input.validation-passed,
- validation-advice

It looks like a good client side validation choise,
Does anyone has tried this?

--
Fred

Kevin Dangoor

unread,
Jun 24, 2006, 9:31:10 AM6/24/06
to turbo...@googlegroups.com
On Jun 24, 2006, at 6:47 AM, gasolin wrote:

>
> FYI, There's a prototype(a js library) based form validaton library
>
> http://tetlaw.id.au/view/blog/really-easy-field-validation-with-
> prototype

I don't believe that validation is a hard problem.

Beyond that, I really want to see (and think we can accomplish)
extending FormEncode validators to have a client-side component. By
leveraging widgets, we can have little snippets of code that show up
on the client side, making for efficient validation. Plus, many
validators can be reduced to a regular expression, which can work on
both the Python and JavaScript sides.

I wouldn't dissuade you from wrapping that up as a widget if you want
it though. BTW, the Scriptaculous widget includes the Prototype widget.

Kevin

gasolin

unread,
Jun 27, 2006, 12:19:08 PM6/27/06
to TurboGears
Hello Kevin:

Acturally this lib is a regular expression based validation, so its a
good point to start for client/server validators.

The current owe is this validation require to import additional
prototype/scriptaculous libs.
Since mochikit has porting some prototype/scriptaculous feature, maybe
we can expect future support for mochikit native client side
validation, too.

I've made a patch for scriptaculous widget (#1017) to make
scriptaculous update to 1.6.1 (it will use prototype 1.5pre0, field
validation library depends on it)

and put the development version of field validation widget in
Sourceforge's svn if anyone intrested in it
http://sourceforge.net/projects/tgwidgets.

regards

--
Fred

Kevin Dangoor

unread,
Jun 27, 2006, 8:46:25 PM6/27/06
to turbo...@googlegroups.com
Hi Fred,

I'll try to get those widgets updated soon.

Regular expression validation should not be overly difficult. TG's
own JavaScript-based validation, when we have it, won't require
scriptaculous... (which, of course, is never a reason to stop what
you're doing :)

Kevin


--
Kevin Dangoor
TurboGears / Zesty News

email: k...@blazingthings.com
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com

Reply all
Reply to author
Forward
0 new messages