YAV tags


YAV-tags is a JSP library tag for YAV Javascript validation tool

YAV is a javascript library which provides web forms validation via Javascript.

YAV-tags makes easier to use this library from JSP pages and adds server-side validation.



YAV-tags 1.0 beta is out!

You can download it at sourceforge YAV-tags project download page.

This release implements all YAV rules on the server side having no known critical bugs. During beta stage we expect to discover and fix any bug, in order to release a production-ready version.

In case you experiment any problem, please report it at the YAV-tags bug tracking system.

Quick start

  1. Add yavtags.jar to your application's classpath (usually, WEB-INF/lib folder).
  2. Configure the filter in your web application descriptor (web.xml) like that:
    replacing *.do to suit your needs.
  3. Link Yav javascript code adding this configuration into your web.xml:
  4. See advanced configuration for further details, specially if you need multipart uploads support.


Basic usage

  1. Add tag library declaration at the top of your JSP (it could be in an include fragment or JSP prelude):
    <%@taglib prefix="yav" uri="http://net.sf.yavtags"%>
  2. Surround HTML form with validate tag: <yav:validate>
       <form action="xxx.do">
  3. Add a rule tag after every field that you want to validate:
    Username: <input name="username" type="text" />
    <yav:rule value="username|required" />
    Age: <input name="age" type="text" />
    <yav:rule value="age|integer" />
    Rule syntax is YAV's one.

Help tips

You could add a tip for a field like that:

Username: <input name="username" type="text" />
<yav:help for="username" message="Provide a short username" />

Custom masks

Custom masks are defined this way:

Birthday: <input name="birthdate" type="text" />
<yav:mask name="myDateMask" format="  /  /    " chars="0123456789" />
<yav:rule value="birthdate|mask|myDateMask" />


At the client side YAV-tags simply generates the Javascript and HTML code required by YAV library.

While generating this Javascript code YAV rules are stored into the web application's ServletContext object, mapped to the form instance.

When form date is sent to server, request is intercepted by a servlet filter, who checks stored validation rules.

In case of a validation error, it shows encountered errors via a ServletException.

Technical documentation