rickharrison/validate.js — pull request #27 by templaedhel (2012-07-07 02:29:27+00:00)
Title: Added a callback option to the field objects

Now you can specify a function that is called on the change event of each input. The function is passed two parameters, value and event.

value is the value of the input
event is the event (if supported)

This is useful for showing hints/client side warnings before submit.

An example is as such

````javascript
validate_pass = function(value,event){
var element = event.target;

if (value.length < 8) {
$(element).addClass('warning');
alert('Your password is too short')
}
}

var form = new FormValidator('sample_form', [{
name: 'password',
rules: 'required|min_length[6]',
cb:validate_pass
}],function(errors,event){
//Handle the actual form submit event
})
````