Tuesday, August 07, 2007

An easy way, XHTML standard, accesible and usable, library for form validations using JavaScript with the powerful libraries jQuery and YAV.

 

Background

Web forms are the standard way for to obtain input data of the users. As usual, you allways need to validate the input data before to accept them (store in the database, work with them, ...) , so the server-side validation is neccesary because errors in the input data can generate errors in the server code (clients without javascript, direct posts,...). You have different alternatives for server-side validation, using frameworks (CodeIgniter for PHP or Apache Wicket for JAVA are some examples of web forms validation routines) or programming all the code lines for to validate the input data from the user (more tedious).

But there are some thoughts about you prefer validate also the web form in the client side:

  1. Is faster. You don't need send the form and wait the response from the server.
  2. Major interactivity.
  3. More usable interfaces.

In internet, there are some examples of different sort of javascript validation, programming directly each validation routine (Javascript form validation – doing it right, Form validation,...) or with a javascript library (JavaScript Form Validations Made Easy!, JavaScript Form Validation, the Aspect-Oriented Way). The libraries are preffered by the programmers because reduce the code that they write but normally these libraries are focused to the data validation but not in the later error representation, so the main validation function only returns true or false, or a list of fields with the errors and the programmer normally show the errors all together in an alert box or in a custom place in the web page (a div) or colour the error field. These methods of error representation can be improved focusing to accessibility and usability:

  1. A normal alert box showing the errors is not usable and not accessible because, after to click in the OK button, the user have not visible what is the field with the error. You need mark with a accessible way the field.
  2. Colour the field is well, because the user can see the problematic fields fastly (usable), but is not accesible (what about with visibility problems people). You need write near the field, preferably in the label of the field.
  3. Move the focus to the first error. If you update the page content with JavaScript, and the user is in the bottom of the page, probably, the changes are not shown by the user. You need scroll the page and focus the first element with problems or error message.

There are two libraries (that I know) with more advanced options for web forms validation, jQuery Validation plugin and YAV. These libreries are very good but I have found some problems with them:

  • You have to set a list of rules for each field to validate and the error messages in the JavaScript (Validation plugin and YAV). YAV is more tedious because the conditional rules require to set the proper indexes of the condition rule in the array of the rules. Also, you need then different JavaScript code for different language messages (english, spanish,...) although normally the language translations are in the templates.
  • Awful class names like class="{required:true,email:true}" (Validation plugin).
  • Custom validate attribute is not W3C standard (Validation plugin).
  • The error results are not associated to each field (YAV). Then the programmer have not a easy way to write an error message near the field.
  • Relationship rules. Only YAV has relationship rules like and, or or implies. Also you can set a rule of relation of other relation joint like (field1 and field2) or (field2 and field3).
  • jQuery Validation has a perfect control over where the error messages are shown but it is not the same in YAV. YAV only show the errors as a list using a layer or an alert message. You can not set individual message related with the error field (YAV).

So I'd need some similar but only with the good things of these plugins and without the problematic things (no W3C attributes, ...). This was my target for the spare time in my holidays.

jQuery.YAV plugin makes easy the web forms validation

jQuery.yav is a new plugin for to integrate YAV form validation wih jQuery, making the form validation more easy, accessible, usable and W3C standard. Now you can validate forms with a more easy form, and if you like, you can get all the power of the custom and extended setting of this plugin, setting more complex validations. jQuery.YAV add also, a little bug repair for YAV library for multiple values in class attribute and not requires yav-config.js file. Tested in IE 6 and 7, Firefox 2, Netscape 7, Safari 4 for Windows, Konqueror 3.5 in Linux and Opera 9 but must work in jQuery compatible browsers.

Changelog
Open changelog

IMPORTANT: YAV 1.4.0 library introduced a bug working with multiple classes, you can download a patched version or wait for the future release :-)

Download

 jquery.yav.js (uncompresed version) or  jquery.yav.pack.js (compressed version, only 4kB) and the documentation

The plugin requires jQuery (MIT/GPL license) and YAV (GPL license) libraries.

Documentation

jQuery.YAV set all predefined rules of YAV as simple class names. So you can validate simply set the proper class name. If the rule fails then the title of the field is shown as error message. This is for accesibility improve, so screen readers can read the guidelines of the field. jQuery.YAV capture the "onsubmit" event and if the validation fails the form is not submitted.

Basic example (run the example)








JavaScript code:
 $(document).ready(function(){
$("#form1").yav();
});

Username field has two classes (required and alphanumeric) and the title attribute with the message, also in email field has required and email classes. This classes works as normal css classes but also as validation rules, so any form field with this rules will be validated.

The pre-defined validation classes are the same of YAV: "alnumhyphen", "alnumhyphenat", "alphabetic", "alphanumeric", "alphaspace", "date", "date_le", "date_lt", "double", "email", "empty", "equal", "integer", "keypress", "maxlength", "minlength", "notequal", "numeric", "numrange", "regexp" and "required".

If any rule requires some parameter you can set in the alt attribute with a especial syntax. Alt attribute in form fields in the standard XHTML is of type CDATA so, you can write any code and this is XHTML valid!.

Also if you use more rules, you can set params as array of params (you need set an empty array param for the rules that not requires params). The params is in alphabetic order of the rules:

Basic example with field event validation(run the example)








JavaScript code:
 $(document).ready(function(){
$("#form1").yav();
});

Alternatelly you can validate a form field on event trigger using the event parameter. This parameter is a event or a comma separated event list.

Custom rules example (run the example)








JavaScript code:
 $(document).ready(function(){
$("#form1").yav({
errorDiv:"mainError",
errorMessage:"Some errors are found, please correct them",
custom: {
myCustomRule: function(return_value, param1, other_param){
var field_id = return_value.id;
if ($("#"+field_id).val() == param1){
return null;
}else{
return return_value;
}
}
}
});
});

You can set others new validation rules and use them as class names like pre-defined validation classes, the HTML code is the same, and if your custom rule has params, you can set the params with the same way of pre-defined rules. In the yav plugin call, you can set the config parameters as a map variable (pairs of key: value). A special param is "custom" and this is also a map variable with the custom rules definitions name_of_the_rule: function(...).

A custom rule allways has a first param (called in the example as return_value) with the id and the msg for to show the error. For a custom rule works, the rule must return null if the rule is passed or the first param on error. Alternately, you can use this param for to get the id of the associated field.

In this example, we can set a top message, indicating that there are found errors. This settings are configured with "errorDiv" and "errorMessage" param. If errorDiv is not found in the page, the message is not shown. The webpage scroll to the first error or the errorDiv in each case. This setting is for usability and more accessibility improve.

Advanced config options and setting yav configuration variables and AJAX(run the example)








JavaScript code:
 $(document).ready(function(){
$("#form1").yav({
errorDiv:"mainError",
errorMessage:"Some errors are found, please correct them",
errorClass:"verror",
errorTag:"span",
errorPosition:"parent().before",
custom: {
myCustomRule: function(return_value, param1, other_param){
var field_id = return_value.id;
if ($("#"+field_id).val() == param1){
return null;
}else{
return return_value;
}
}
},
onOk: function(form){
$.post(form.action,{
text: $("#text").val()
},function(server_response){
alert("User says: "+ server_response);
});

return false;
},
onError: function(){
alert("Please correct the errors");
return false;
}
},{
inputclasserror: "markererror",
errorsdiv: "yaverror"
});
});

This example shows how set more advanced settings of the plugins. In the call of yav plugin, we have two map params, the first is the plugin config params, the second is used for to change the default YAV settings (see YAV documentation), the names of the configuration variables in the second  parameter are the same name as YAV original library.

In the first param, we have some control variables for jQuery.YAV plugin, errorDiv and errorMessage sets a top error and advice to the user. errorClass set the class of the errors when they are shown (by default the class is "error"), errorTag set the tag that enclose any error message (by default is a "p" tag, you can use "div, span, etc..."), errorPosition set the position related to each error field using the name conventions of jQuery (after, before, parent().before, parent("tr").next("tr").html, ....).

Two more config variables you can use, onOk and onError. This config variables are functions with one param (a reference of the validated form). If these functions returns false, the form submit is cancelled, if returns true or none the form is submitted. You can use this functions for to execute any code post-validation, by example, we can use onOk function for to submit the input data using AJAX, and cancelling the normal form submittion. You can use one, two or any of these functions.

Working with relationships between rules (run the example)









JavaScript code:
 $(document).ready(function(){
$("#form1").yav({
errorDiv:"mainError",
errorMessage:"Some errors are found, please correct them",
errorPosition:"parent().before",
custom: {
myCustomRule: function(return_value, param1, other_param){
var field_id = return_value.id;
if ($("#"+field_id).val() == param1){
return null;
}else{
return return_value;
}
}
}
});
});

This example shows a basic relation between two fields. This fields are related with a conditional and so, we will show another message if the two rules are passed. This relationship is set from the HTML code inside the alt attribute. In the alt attribute of the first field, we have a condition configuration, this condition has the next structure:

condition: { name: 'any_string_identifier', type:'and|or|implies', msg:'Error message to show'}


Alternately, you can set also, a id variable in the condition, with the id of the field that the error will be show, by default is the first field with the condition configuration. The next field only configure a condition using the name identifier, so, any field configured with the same condition identifier are conditioned to the same relationship.

In the previous example, the two rules are checked and generates an error although we remove the relationship, but if I don't want shows the individual errors but I want show the relationship error, I can set a requirement, in the alt attribute, we write the require setting with the valid values: pre-condition or post-condition (for implies relationships).

alt="{require:'pre-condition',condition: { name: 'any_string_identifier', type:'and|or|implies', msg:'Error message to show'}}"

Multiple condition and groups of relationship (run the example)

You can set relationships over other relationships. So we have 4 fields (A, B, C and D), we have related A and B, later we have related C and D, we also want a relationship over the first group and the second group with a or condition, by example, so we have: (A and B) or (C and D).









JavaScript code:
 $(document).ready(function(){
$("#form1").yav({
errorDiv:"mainError",
errorMessage:"Some errors are found, please correct them",
errorPosition:"parent().before",
custom: {
myCustomRule: function(return_value, param1, other_param){
var field_id = return_value.id;
if ($("#"+field_id).val() == param1){
return null;
}else{
return return_value;
}
}
},
onOk: function(){
alert("The validation is passed, please note that is the field is empty the rule is passed");
return false;
}
});
});

As you can see in the example in the first field, we have set two conditions in the alt attribute, so condition config also can be an array of relationships. In the second condition we have set a new configuration value group as array of relationship identifiers.

{name: 'identifier_of_relation_group', type: 'or', group:['one_identifier', 'other',....], msg: 'message to show on error'}

Also as you can see, a condition (relation) can have a require value, the same as a normal rule.

Labels: ,

61 comments, Post a CommentPosted by posted by SeViR @ 10:12 PM
61 Comments
Aug 8, 2007 4:42:00 PM, Blogger abmcr said:
Very best!!!! Thank ypou: i have used Yav, but in this way all is very simple. Ciao!!

Andrea  
Aug 9, 2007 4:43:00 AM, Blogger Venu Reddy said:
Sounds good. But examples does not work in IE7.  
Aug 9, 2007 9:17:00 AM, Blogger SeViR said:
Thanks for the comment about IE7, script debugger shows an error in jQuery, the line have no errors ¿?¿?. I just download Web Developer Express, bugg 250MB only for IE debug ;-(.

I will see what is the problem.  
Aug 9, 2007 10:25:00 AM, Blogger SeViR said:
IE problem repaired, an extra comma in the code ;(. I hate the cryptic information of debugger in IE.

Now tested in IE 6, 7, Firefox 2, Safari 4 for Windows, Opera 9, Netscape 7 and Konqueror 3.5 :D  
Sep 5, 2007 11:08:00 PM, Anonymous Jörn said:
Hi Sevir,

I found quite a few very interesting ideas here, ie. to simplify error placement specification.

I've started the work on my validation plugin more then a year ago and still have no exact idea how many people are using it, but considering the comments on the plugin page it seems like there are a lot. I'd like to propose to combine our efforts to provide the best JavaScript form validation available, instead of splitting it up. It looks like you have the ideas and the time to implement them that I am lacking.

The problems you found in my plugin are all solvable: I have an approach for metadata without ugly class-attributes lying around. The dependency-stuff isn't very well documented but very easy to setup and so far worked for every usecase that came up. Improving examples and documentations seems to be the key for that feature.

Please contact me via mail or IM (GTalk, same address as email) if you are interested (joern.zaefferer at gmail.com). I couldn't find your address here or on sevir.org.  
Sep 10, 2007 12:43:00 AM, Anonymous Marco Antonio said:
Sevir, great job. I'm using Jorn's Form Validation and realy like that. Form Validation haves a very nice approach seperating error message and validation routine. YAV allows this? Once more: congratulation.  
Sep 13, 2007 8:21:00 AM, Blogger SeViR said:
Marco, in fact, error messages are separate of the field, and using CSS or some minimal JS code onError function you can move the messages to any placement.
You can see Another Ideas using jQuery.YAV.
jQuery.YAV maybe has not more flexibility because is focused to accesibility. In other hand, I am now in contact with Jörn for improve his Form Validation Plugin.
With the latest jQuery.YAV 1.1 version, this plugin doesn't renew no more, only I made bug patches.
Our efforts are for improve Form Validation Plugin.  
Sep 13, 2007 7:07:00 PM, Blogger Mark said:
Very nice. I was looking for a nice dynamic form validation and this will suit the purpose well.

Thanks! :)  
Sep 21, 2007 10:26:00 PM, Blogger lithiumdave said:
I love this solution, I've been looking for something as simple as this for validation for some time, especially as I'm not naturally a programmer.

I really love the example you gave here:

http://projects.sevir.org/storage/yav/advancedsettings.html

I love this one because of the way the actual input fields themselves are given a class, as well as the general 'you have errors' message is output too.

My only problem is that I don't need AJAX with my forms, just to simply send the form if all validation is passed.

Sorry to be a little bit slow but I don't understand how to adapt this example so that it keeps all the wonderful error reporting but simply sends the form (to the URL given in the form 'action'), rather than calling for a server response.

If you could help me out I'd appreciate it.

Thanks for the good work! : )

Dave  
Sep 27, 2007 5:41:00 AM, Blogger Jon Lesser said:
I am trying lots of things, but not getting how to give the parameters for numrange. Can you tell me what should be in the alt attribute to specify a numrange between 0 and 60.

Thanks!  
Sep 27, 2007 3:49:00 PM, Blogger SeViR said:
lithiumdave:
If you need send the form if the validation is passed you have two options:
1. Not using onOk callback function, the validation submit the form if is passed.
2. If you need post-validation code, use onOk function but this functions must returns true instead of false (canceling form submittion).

jon lesser:
this is a simple html sample,
< input name="test" id="test" title="Write only a number between 0-60" class="numrange" alt="{params:'0-60'}" / >  
Oct 8, 2007 4:34:00 PM, Anonymous somedude said:
Hi there!

Thank you for a great plugin! But I really think you should try to port the YAV lib into a jquery-only-plugin. Mainly to reduce the size of all required javascript lines.

Keep up the good work! Cheers  
Oct 9, 2007 8:16:00 AM, Blogger SeViR said:
thanks somedude,

really there is a jQuery-only plugin for validation that it is Validation plugin of Jörn.

I have pending to revise Jörn plugin and test all its possibilities, but I have not any time now, full work :(  
Oct 11, 2007 1:04:00 AM, Anonymous Jacob said:
Hey Sevir,
I found your plugin a while ago, but now I had a closer look at it and it looks very good! Especially the accessibility things are very good! But, like somedude said, a jQuery-only plugin would be a bit better. I would appreciate if you and Jörn would create one (or modify his) that has as much features as yours, is so simple to implement like yours and has the same focus on accessibility.  
Oct 18, 2007 2:13:00 AM, Anonymous Somedude said:
@sevir:

But Jörn's validation plugin just isn't the same. The YAV library keeps the HTML semantics and CSS classes so clean. And the need for no configuration together with all the accessibility aspects just makes YAV unbeatable.

But the size of required http requests is a minus...

My advice would be to modify your library into a standalone plugin, and remove some fancy and unnecessary features to gain performance. I would love to help you in the development. But javascript just isn't my thing. I'm on the server side ;)  
Oct 18, 2007 12:12:00 PM, Blogger SeViR said:
@Somedude:

The validation core of jQuery.YAV is YAV because is my first option for JavaScript validation so, I thought to make an accesible and usable plugin for YAV.

Is Jörn validataion plugin unaccesible? I think that the response is not.
1º It is true, Validation plugin use classnames like {rule} and it is more clear class like myrule and set the params in other places. My first option in jQuery.YAV is to use alt attribute but selects and textareas hasn't alt attribute in the XHTML standard, so I let the possibility of set the params in the class attribute also.
2º Also it is true that Validation can grow in accesibility features like error messages in title attribute but this is a minor change.
3º In Jörn plugin can set all the rules in JavaScript so this is allways XHTML standard.
4º We are reviewing if Jörn plugin has the same possibilities with relationships between the rules, and maybe to incorporate into the Validation plugin this options.


Really, Jörn plugin grows faster, so why we can't to incorporate similar jQuery.YAV ideas in Jörn plugin? Soon you will see the results :)  
Oct 20, 2007 8:59:00 AM, Anonymous webspin said:
Great Plugin!
I've been able to get everything I want done with it, except I have one problem. I have a multi-part (multipage) form with BACK and NEXT buttons on it. When the user clicks the BACK button, I DO NOT want ANY validation to take place. At the moment, I have only figured out how to use the onError: configuration and if NEXT has been pressed, I use an onClick event on that button to set a global variable which is checked in the onError: config function, and if this is set, returns true to allow the user to navigate backwards, but however, validation still takes place, so the error div's pop up very briefly. I would like a way to completely dis-engage YAV from the #form element as takes place in the $(document).ready function. IS this possible? Thanks very kindly for all your hard work.  
Oct 21, 2007 1:08:00 AM, Blogger SeViR said:
@webspin:

In fact, it is possible. I don't know how your page is, but a simple method is only next button is a "submit" button, the back button can be an input type="button" so, the validation never dispatch in Back click. Your problem I think, is your method for reload the previous form step, that you maybe need submit the form. If you allways submit the form in Back and Next button, you need unattach the submit validation handler before submit the form on Back:
$("#mybackbt").click(function(){
//unattach the validation submit handlers attached with yav
$("#myform").unbind("submit");
//submit normally, maybe with some param in a hidden field??
$("#myform").submit();
});  
Oct 24, 2007 6:15:00 AM, Anonymous Anonymous said:
Does not work with YAV 1.4.0, just to let you know.

Great job!  
Oct 24, 2007 10:26:00 AM, Blogger SeViR said:
The new release 1.2.0 is compatible with jQuery 1.2.1 and YAV 1.4.0

Also works with the old versions of jQuery and YAV detecting the version and patching correctly YAV for multipleclassname in old versions < 1.4.0  
Oct 28, 2007 2:56:00 AM, Blogger admin said:
This post has been removed by the author.  
Oct 28, 2007 3:18:00 AM, Blogger admin said:
This post has been removed by the author.  
Oct 28, 2007 3:22:00 AM, Blogger admin said:
Ola Jose, muchas gracias por su trabajo sobre Yav!

I would just have 2 questions:

I am using your jquery script + yav along with the tutorial found in your post dated 9th of August: "Some ideas using jQuery.YAV plugin". the problem is:

using the 1st example on your tutorial, my input boxes use a certain style and when there is an error in the form, YAV kicks in and the style applied to these boxes no longer works. (the input boxes revert to normal boxes without the style I declared in my CSS file)

I tried to tweak #errorcontainer without any success.

And, is it possible to display ONLY the error in the pop up and not above the textboxes (case of a normal JS popup) ? (the yav demo shows this is possible but didnt find a way using your script)

I intend to use yav + your jquery script on all the website, this would really help if you could give me a hint :)

(sorry for my broken spanish...)

gracias  
Oct 28, 2007 9:20:00 PM, Blogger SeViR said:
@admin:

two thing:

first, if your input boxes change the style is for a problem with something of your code, if you see the idea1 sample file with firebug, you can see that when there are one error in a field, the input is marked with a special style (by default is "c", so if you have not any ".c" defined in CSS, your style is applied. I suppose that your input style is defined as:

< input class="yav_rule yourcssclass" />

So after the validation your input can be
< input class="yav_rule yourcssclass c" />

yourcssclass must be applied also and remaining your style. I have never this problem. Maybe your style definition have some problem.

Second, jQuery.YAV is focused for usability and accesibility, so the first application for this plugin is with errors displayed near the field (for screen readers improve), you can set the message above o below, in other td in a table... but allways related with the error element.

The idea explained in "Some ideas..." post is for play with more options with this plugin but is not the focus of the plugin. Using the ideas of that post, you can set the messages inside a DIV and remove the messages above the fields.
You say, YAV has this possibility, sure, but original YAV is not focused for accesibility ;)  
Oct 29, 2007 5:38:00 AM, Blogger admin said:
ola jose, muchas gracias por su respuesta.

I have worked on that yesterday.
on IE 6 and 7: plugin works 100% ok
on firefox 2 problems occur.

- I have checked the syntax on the example. it appears that if i use "required email input c" the style changes after i submit the form (.input being the style i use for my textbox). there is no problem if I use "required alphanumeric input c" though.

- after submission a pop up appears (normal) then if i click the submit button again (without filling up the form) the form is processed...

on IE 6 and 7 it works just fine though. if i dont fill up the form and click again the pop up message will appear.

hope this is a slight bug in the code somewhere and not jsut me fooling around with the script.

do you have any idea on how to make it work with "required email" + avoid submission if fields are left blank please?

checked the syntax in the example 1. I have added a "c" to my own syntax and it works slightly better.

now what I have is:  
Oct 29, 2007 8:39:00 AM, Blogger SeViR said:
Hola admin,

the "c" classname is useless if you don't have a class definition in your CSS, this classname is custom with (inputclasserror):
$("#theform").yav({
//plugin params configuration or empty object
},{
inputclasserror: "anotherclass"
});

If your form is submitted without validation in the second try must be because there is a javascript error in the onError function code (I suppose), in Firefox if the code faults, the next tries of submit doesn't run the javascript code and submit normally. Do you have Firebug for Firefox? it will help you for debug these errors.

Finally, about email field empty, the simple "email" rule has this behaviour, but if you set "required" also, the field can not be empty ;-). So you need only the class "email".  
Oct 29, 2007 11:12:00 AM, Blogger admin said:
hi,

i have a class called "input" (i define the border color etcetc)

i am using the stantard javascript pop up in your example.

using the "c" works only with the password field, not with the email field.

so:

- works just fine on IE 6 and 7
- on FF 2: 1st try, the email textbox style is changed for the standard style and not the one that is defined in my css. on 2nd try: the form is processed...

i use firebug and dont see anything wrong in the way the job is handled.

the css has been working ok so far... (using another js for validator it works 100% ok)

i really ont know where it comes from :(

hope i shed some light on the problem and that you can help me out on this one :)

thanks!  
Oct 29, 2007 11:38:00 AM, Blogger admin said:
i dont know whether it comes from he plugin or not but:

- if I use "required email input i":
my css is not used after validation. and 2x try processes the form.

- if I use "required email input c": the css is not used after validation. and 2nd try processes the form.

- if I use "email input c": my css is used after validation. BUT 2nd try processes the form.

- if i use "required alphanumeric input i" instead of email my css is used BUT 2nd try processes the form.

hope this helps in telling me where the problem may come from.

been looking in the jquery script but didnt find anything relevant... :(

thanks! :)  
Oct 29, 2007 9:39:00 PM, Anonymous Anonymous said:
Hello.
I'm having some problems with this plugin in firefox.
I don't know the reason, but when i click twice on submit buttom the validation procedure doesn't work.  
Oct 30, 2007 8:58:00 AM, Blogger SeViR said:
anonymous:

There are no problems with Firefox in my tests and neither with my partners tests (all the programmers of my University works with this plugin).

Can I see your code? something sample duplicating the fault?  
Oct 31, 2007 4:07:00 PM, Blogger Jeroen said:
@anonymous && @sevir:

I also got the bug anonymous reported. The fact was, I did nothing fancy. (Tidy reported 0 errors and dito warnings)

Let me discribe it step by step:
1 Submit the form
2 Errors appear like they should
(When using Firebug the classnames where all mixed up, for instance using 'required alphaspace' said, after the first hit on the submit button, 'requred alphaspae i c'.)
3. Correct the userinput in the form, well, or not ;)
4. hit submit again
5. the form submits with faulty data

The problem is of course that the classnames are all fubar after the first hit on the submit button. My quick fix is to set the 'inputclassnormal, inputhighlight, inputclasserror' in captials so they do not interfere with the validation. I'm guessing that somewhere along the road the letters for these parameters are filtered out? (Haven't spend that much time on it.)

Also there is a small minor other bug in the jquery.yav code. On line 377 it says '//doesn't check null value because if eval works this object has a rule' well that's not true, the null check has to be there otherwise you'll end up with some null-rules in your rules-array.

All and all it's a very good adition and I'll continue to use the jquery version of yav. Maybe you can use my comments to make the whole lot better.  
Oct 31, 2007 6:54:00 PM, Blogger admin said:
hi there, to those who have a problem with Firefox, please use a previous version of YAV as it seems the way the class is handled has changed a bit.

I have tried and it solved 90% of the problems.

If some of you know how to check whether 2 fields are identical in a form I am interested :) (like checking if email and confirmation email are identical)

+++  
Nov 4, 2007 10:58:00 PM, Blogger SeViR said:
@Joroen:

This is a bug of the new version of YAV, and not is in the plugin. The old version of YAV < 1.4.0 works perfectly with the plugin.

Sadly, I recommend a multiple classes support in YAV core library to Federico (the creator of YAV) but I wrote a wrong regular expression in my recommendation code.

Last week I wrote to Federico again with the fixed code for updating YAV. I wait that Federico updates soon the core library.  
Nov 27, 2007 4:23:00 PM, Anonymous Anonymous said:
Please tell me how do i use the numrange. I've try class="numrange" alt="{params: '0-60'}" and doesn't work. Ths.  
Nov 27, 2007 10:23:00 PM, Blogger SeViR said:
If you need *numrange* rule, you need set two more YAV variables, THOUSAND_SEP and DECIMAL_SEP

sample (the first param is the plugin parameters, I have writed empty):

$("#form1").yav(
{}
,
{
THOUSAND_SEP:",",
DECIMAL_SEP:"."
}
);  
Dec 2, 2007 12:09:00 AM, Anonymous Gerard said:
very thanks for you very nice work you did. Seems there is a little problem with required alphanumeric and accentued caracters as é,è,à and so on  
Dec 2, 2007 9:03:00 PM, Blogger SeViR said:
@Gerard:

Alphanumeric rule no works with not-english caracters, this includes Spanish and Portiguesse accentuaded characters, ciliric russian characters, etc... ;-). Because YAV rules is not "language-centric", the library can not check all the languages possibilities.

Alternatelly, you can to use a regular expression rule for Unicode characters. Here you are a tutorial of Unicode Regular Expressions  
Dec 10, 2007 11:10:00 AM, Anonymous Gueto said:
Excelennt! Though I have 2 questions I couldn't solve. How can I apply styles to the errors div? Also, how to to apply validation to a required select box? Thank you.  
Dec 10, 2007 12:51:00 PM, Blogger SeViR said:
This post has been removed by the author.  
Dec 10, 2007 12:52:00 PM, Blogger SeViR said:
@Gueto:

You can define css style in the error class or anything what you want, you can see more examples in http://projects.sevir.org/storage/yav/.

About select boxes, simply:
sample code

With select, alt attribute is not standard but anyway works, the options in classname is a W3C standard alternative.  
Dec 12, 2007 11:13:00 AM, Anonymous Gueto said:
Thank you very much :)  
Jan 2, 2008 6:09:00 PM, Blogger Diego Henrique said:
I would like to leave all the settings to validation in a js file. It is possible?  
Jan 3, 2008 9:17:00 AM, Blogger SeViR said:
@Diego Henrique.
You can do it, you can write a set of configuration variables in a separate js file, because the jquery.yav params are js objects.

Here you are an example  
Jan 22, 2008 2:01:00 PM, Anonymous Anonymous said:
hi - I'm confused with getting past the basics

eg:
<input id="email" class="email">
<input id="phone" class="alphanumeric">

I want email OR phone to be required but the ALT syntax is beyond me.. Please help!

What is the naming conventions? its not the field name? etc

email OR phone inputs must be filled out....  
Jan 22, 2008 7:57:00 PM, Blogger SeViR said:
@anonymous:

At first, we have no name convention, because the plugin works using the ID. You can use "name" attribute as usual (some AJAX calls don't need this atribute, but of course for normal submit, you need write the name of the parameters to submit).

Second. You need a conditional rule:
< input id="email" class="email" alt="{require:'pre-condition', condition:{name:'eORp',type:'or',msg:'please write your email or your phone'}}">
< input id="phone" class="alphanumeric" alt="{require:'pre-condition', condition:{name:'eORp'}}">

The first field setup the condition, the second, only write the condition associated. The param require is neccesary so the rules 'email' and 'alphanumeric' are not checked separately of the condition.  
Jan 31, 2008 7:36:00 PM, Anonymous Anonymous said:
Hi, I am also interested in the group popup error message implementation idea. I know you said it's not your focus. Just wonder if you have gotten to that yet. yav provides a classic way of validation, which is the group popup. The problem I have with the inline style is that it might confuse the user when the form all the sudden changes.

If there is an easy switch to change the validation mode from inline to classic, please advise.

Thanks  
Jan 31, 2008 8:25:00 PM, Anonymous Anonymous said:
Hi, I noticed that the "title" is required for error message, could you put in some default error messages so that when "title" is missing, it will say something like "The field [field name] is required" or something like that?

Thanks.  
Jan 31, 2008 9:45:00 PM, Anonymous Anonymous said:
Hi, I am just curious. When YAV release more validators, will your script pick it up? Or do you have to implement any new validators that might be released?

Thanks.  
Feb 6, 2008 9:12:00 AM, Blogger fc said:
Hi,
I am Federico Crivellaro, the creator of yav. I have released yav 1.4.1 (http://yav.sourceforge.net) with some patches, so some pieces of information in this page are outdated. More important, I will release in a few weeks yav 2.0 with more powerful features (ajax, events, new rules, and other), and a syntax really simple (I hope). If you have suggests send me a mail, thank's a lot!  
Feb 9, 2008 12:36:00 PM, Blogger Dejitaru said:
Have someone create a page to use all validations types? I cant make it work some of them like the DATE.. A full example page will be usefull. Thanks  
Feb 9, 2008 12:57:00 PM, Blogger fc said:
See yav.sourceforge.net for a page with all validation types using yav (without the jQuery plugin).
when I will release yav 2.0 (as soon as possible), I will create a page with jQuery.yav and a lot of examples inside the official yav site.  
Feb 22, 2008 3:50:00 PM, Blogger mesh said:
Hi!

Very nice work.
But I have a question...
Is it possible to somehow trigger form validation before submit?
I have a form (multipage) in modal window. First part consists of fields that need to be validated. Second page is optional. I would like to trigger validation with the click on element which hides first DIV (first page) and shows second page but before submitting the whole form with submit button on the second page.
Is that possible?  
Feb 22, 2008 4:10:00 PM, Blogger fc said:
It's possible with yav 2.0 soon available. Stay tuned!  
Feb 24, 2008 8:54:00 AM, Blogger mesh said:
Great!

I wait impatiently :)  
Feb 24, 2008 4:37:00 PM, Anonymous Anonymous said:
Can someone help, I have copied the basic example and I can't get it to work. Tried everything. Thanks. Link: http://comfypad.dreamhosters.com/js/index.html  
Feb 24, 2008 5:00:00 PM, Blogger zippy said:
Ok I looked into it and it doesn't work with YAV 1.4.1  
Feb 24, 2008 5:45:00 PM, Blogger zippy said:
Is it possible to set the styles of erros like the ASP.Net way of client side validation. You get one area with the error messages in it. I see in YAV you can have type innerHTML where it does this and highlights the fields with errors. How do I implement this here?  
Feb 24, 2008 6:57:00 PM, Blogger fc said:
We are working hard on yav 2.0, and jQuery.yav will be updated too. We have a new discussion list here:

http://groups.google.com/group/yav-en/

We hope you join it posting there all your comments, ideas, questions about yav and jquery.yav. Thank's for your feedback, it's important to improve this tool!  
Feb 25, 2008 1:20:00 PM, Blogger zippy said:
Can someone look at http://comfypad.dreamhosters.com/js/index2.html and tell me why its not working. I dont believe its doing the traversing properly. The page onload finds the element but YAV doesn't  
Feb 25, 2008 2:01:00 PM, Blogger fc said:
Sorry, by now I'm very busy in my job, so I can support you only about yav. Post your question in the discussion list: http://groups.google.com/group/yav-en/
regards.  
Apr 25, 2008 2:28:00 PM, Blogger WEBAPPL.DEV said:
Here's how to check two passwords are the same.
In the second password field use the class rule 'equal' and then alt="{'params':['$password']}" the $password is the important bit and means the value from the field with the name 'password'  
Links to this post
This design is under copyright of SeViR CW © 2007