20041008 Friday October 08, 2004

fValidate - a Kick-Ass JavaScript Validation Library I found this gem from Ben Alex on the Spring Forums tonight. fValidate looks to be an awesome client-side validation library. If you do a view-source on the aforementioned page, you'll see that all the validation rules are specified in the "alt" attribute of input elements. Apparently this is XHTML valid. Since the current implementation of WebWork in AppFuse doesn't have client-side validation, I may have to hack something together tonight. From the looks of it, this will simply involve adding an "alt" attribute to the existing WebWork tags.

Later: I think I'll pass on the AppFuse/WebWork integration - it looks like a fair amount of work and I'd rather just get 1.6 finished and released. Posted in Java at Oct 08 2004, 10:46:14 PM MDT 14 Comments

Comments:

You can even specify the error messages using an "emsg" attribute. So you can use exactly the same resource file-derived error messages as used by your server-side Validator implementation. eg:

<@fremerx.formInput "address.addressLine1">
alt="blank"
class="required"
emsg="${springMacroRequestContext.getMessage("required.addressLine1")}"
maxlength="50"
tabindex="1"
</@fremerx.formInput>

(The above is a FreeMarker macro which delegates to resource files for localisation of labels, field help, accesskeys etc.)

Whilst on the subject of pretty good (tm) JavaScript libraries, for client-side table sorting we're using http://webfx.eae.net/dhtml/sortabletable/sortabletable.html. There is a demo link at the bottom of the page. There are many sortable table implementations floating around, but this one happily lives within an XHTML doctype and has a documented API.

Posted by Ben Alex on October 09, 2004 at 12:47 AM MDT #

hey thats pretty sweet, would be a nice option for webwork to have

Posted by francisco hernandez on October 09, 2004 at 01:18 AM MDT #

Ben, do you know how to do this with JSP as the view ? emsg="${springMacroRequestContext.getMessage("required.addressLine1")}" Thanks, Lars

Posted by Lars Fischer on October 09, 2004 at 07:57 AM MDT #

Hi Lars Check out http://www.springframework.org/docs/taglib/tag/MessageTag.html

Posted by Ben Alex on October 09, 2004 at 04:17 PM MDT #

Using the"alt" attribute is only valid in the sense that the markup still validates against the schema. It is definately not valid usage according to the spec, however. See http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-alt for guidelines of using alt.

Posted by Juha Komulainen on October 10, 2004 at 03:37 AM MDT #

I'm used Fvalidate from a long time and it's awesame. It's very easy to add new validators. By te way, you can define the attributes used to specified the validation rule and the error message in the fvalidate.config.js. By default is "alt" and "emsg", but you can use whatever you want.

fvalidate.config.js:
// Attribute used for fValidate Validator codes
this.code = 'alt';

// Attribute used for custom error messages (override built-in error messages)
this.emsg = 'emsg';

Posted by Rafael Muñoz on October 13, 2004 at 02:34 AM MDT #

Matt, This looks pretty wicked! I might see about integrating this with WebWork rather than rolling our own. Thanks for finding this! Patrick

Posted by Patrick Lightbody on October 13, 2004 at 09:23 AM MDT #

peterbailey.net seems to be down, is there a mirror anywhere?

Posted by Paul Barry on October 19, 2004 at 05:12 PM MDT #

No mirror, but it's back up now.

Posted by Ben Alex on October 28, 2004 at 06:28 PM MDT #

<font color="red">'fValidate'</font> <font color="blue" style="vardana">is Excellent client side Validation tool. I found this through Google. Great work. :-).</font>

Posted by Mohammed Imtiyaz on October 13, 2005 at 04:37 AM MDT #

asAS

Posted by 85.165.50.218 on March 10, 2006 at 03:07 PM MST #

OIPOI

Posted by 203.199.250.194 on May 10, 2007 at 11:28 PM MDT #

That is a complete abuse of the alt tag, as Juha noted. Tag abuse is one of the primary causes of the present sorry state of HTML, so please don't encourage more misuse.

Posted by anonymous on June 01, 2007 at 03:10 PM MDT #

el unico problema es que no permite mutiples tag
    para insertar los errores en una misma pagina.....pero es una buneisima herramienta the problem in FValidate is u cant use multiple tag
      in the same page, but is a toooo good

      Posted by Ronhead on October 09, 2007 at 02:23 PM MDT #

Post a Comment:
  • HTML Syntax: Allowed
Click me to subscribe
Matt Raible is a Web Architect who enjoys developing applications with open source technologies. Contact me for rates.
« January 2009
SunMonTueWedThuFriSat
    
1
2
3
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Recent Entries

Tag Cloud