tFormer.js updated to v0.5.2
Sep 07, 2013     22:00:00

28.08.2013 01:35 AM - that was the v0.5 finish time.

tFromer.js finaly was updated with great improvements.


New API

It was actually rebuilded from scratch: new API, new type af work with form elements and still on native JavaScript without any dependencies...

Reason for it is simple - more easy to understand and remember, more logical (I guess:)).

Short list of changes:

var myForm = tFormer('my_form_id');
  • validate method;
  • // new
        myForm.validate();
    // old 
        myForm.validateForm(); // deprecated in v0.5.0
    
  • method for custom field validation;
  • // new
        myForm.field('field_name').validate();
    // old 
        myForm.validateField('field_name'); // deprecated in v0.5.0
    

New element constructors

In new version all fields and buttons are separated objects that has its own methods and options. Wanna work with some field? That is much more easy now:

var my_form = tFormer('my_form_id');
var my_field = my_form.field('field_name'); // => return tFormer field object
// than you can work directly with your field

Also now there is an ability to work with button elements. Submit button automatically will be named as `submit`, all other check button will be named exactly like their data-check attribute.

var my_form = tFormer('my_form_id');
var my_submit_button = my_form.button('submit'); // => return tFormer button object

Events

For now there are three type of events that can be fired by tFormer:

  • tFormer:before - fires just before each field validate function;
  • tFormer:valid - fires for each field that passes validation;
  • tFormer:error - fires for each field that fail validation;

blog comments powered by Disqus