There's a sandbox project trying todo the same, see #1193854: Similar to clientside validation

Comments

Jelle_S’s picture

I took a look at this project and found that it does indeed try to do the same, yet in a different way.

The valform module extends the form api with the '#valform_argumets' attribute, e.g. :

$form['example_email'] = array(
  '#type' => 'textfield',
  '#title' => t('Email'),
  '#description' => t('Must input an valid email address.'),
  '#weight' => $weight++,
  '#valform_arguments' => array(
    array('val_not_empty'),
    array('val_email'),
  ),
);

and allows you to add your own validators with hook_add_valform_validator.
It also validates the php rules that already exist on the form (required, ...)
It's quite a big module, so for now I haven't been able to wrap my head around it entirely.
There are still some bugs in it though, I get the same error message twice for checkboxes (a problem clientside_validation was all too familiar with until recently) and I get it three times for date fields.

That's what I could find after looking at it for about half an hour... I haven't yet found how the existing php rules are converted to javascript validation, but it might be easier if the creator (keepmoving) could explain us a bit more about that

Edit:
This post was about the Drupal 6 version of valform, the Drupal 7 version gave a lot of errors on installation, so I'm assuming that it is still under heavy development

keepmoving’s picture

Yes, the module is still under development. I'm trying to fix some bugs that I found some days ago. The beta version seems to be a bit optimistic. I now believe that it still need a bit long time to achieve the beta level, and would set the version of the module back to '0.5.0-dev'.

Frankly, I decided to write the module about only three month ago. The reason for that was that I failed to find good client side validating module. I did not find any module provide the four key features:
1) conditional validation;
2) validating error message showing for each form item;
3) easy configuration under administrator UI;
4) extensibility with Drupal hook system.

All of the code was written by myself. It needs both experiences of back-end PHP coding and front-end JS coding which is a little big challenge for me. If you or anyone else are interested in contributing to this module, I would be very happy for that.

I'm planning to do:
1) fix some bugs;
2) rewrite the code according to Drupal code style;
3) add comments to both of the JS and PHP code;
4) change extension hook method to a better one.
All of the work will be done in the following one or two weeks according to my free time.

keepmoving’s picture

New feature of Valform 0.8.0-dev :

  • Make error message box floating on the page under the form item.
  • Support webform items, such as webform_time, webform_grid etc.
  • Automatically add validators according webform configuration, for example, file types. See this example.
  • Using jQuery to redesign contextual validator configuration display, no longer affect original form appearance

Any testings and recommends are warmly welcome.

attiks’s picture

My biggest concern is that we are duplicating a lot that's already there, form api has some built in validation, there are modules that add validation on the server and there's this project that's adding the validation on the clientside.

I think this module supports the most of what you want to add, so maybe we better join forces to expand clientside validation, if you want i can give you commit access?

attiks’s picture

Integration with fapi_validation is done, see #1218750: Integrate with FAPI Validation

attiks’s picture

Status: Active » Closed (works as designed)

i'm closing this for now