Hi, i have no idea how to use it in drupal 7. As readme.txt says, no configuration is needed , just install.
Then how can i define my validation rules ? Do i need coding ?

Comments

attiks’s picture

Component: User interface » Documentation

The only thing this module will do is translate validation rules defined in php to javascript counter parts, if you mark a field as required it will create a javascript rule that checks the field on submit.

If you need custom rules for drupal 7, you have to be patient, we are looking into the different options that other modules will/can provide

gorillaz.f’s picture

Oh thanks. Will be happy to wait for your update of this module~

attiks’s picture

What kind of validation rules are you looking for?

gorillaz.f’s picture

for example , there's a text field to fill a user name (not user reference) and i want to check if the user name exist already .
Probably it should be expose to a php validate code. And i'm trying to do it with rules module but find that rules cannot prevent node creation , thus i want to find a way to validate before the form is submitted.

sibiru’s picture

How to use this module with ubercart checkout pane?

mdshields’s picture

There is a link to:
http://validation7.ubu001.attiks.com/examplesform

That is great. It shows how it works.

Can you show the code behind it? I know we always assume someone else somewhere else in Drupal documented this and that. But it would really also help for new people if you could include some documentation. It sucks, I know, because then you have to support documentation on top of code. So, I have an idea.

Could you provide just the code example that is displayed in
http://validation7.ubu001.attiks.com/examplesform
without any description. I would then just copy it, install it on my form module and test it with your module. From there I could definitely figure out everything else.

This is just a suggestion because I am php old school. The only reason why PHP is where it is today is for one reason:
go to:
www.php.net
bottom of page, then click "show source":
http://www.php.net/source.php?url=/index.php

Just the source of the example is all we need (well, at least us newbies).

Main reason I Bring this up... I am just concerned about how to incorporate the jquery file. I'll probably figure it out (include it into my theme info file as an include of js files and it automatically works). sigh... being new in Drupal. I wish there was an easy way we could exchange ideas without all the overhead of documentation... one day someone will find a way where we can easily exchange ideas where we all just get it without any contextual translation.

attiks’s picture

function clientside_validation_example_1($form_state) {

  $form['info'] = array(
    '#type' => 'markup',
    '#value' => '<p><strong>' . t('Clientside validation example - form api.') . '</strong></p>',
  );

  $form['yourname'] = array(
    '#type' => 'textfield',
    '#title' => t('Your name'),
    '#default_value' => '',
    '#required' => TRUE,
    '#maxlength' => 20,
    '#description' => t('Required field, max length 20 characters.'),
  );

  $form['copy'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select at least one.'),
    '#required' => TRUE,
    '#options' => array(
      'status' => t('Published'),
      'moderate' => t('In moderation queue'),
      'promote' => t('Promoted to front page'),
      'sticky' => t('Sticky at top of lists'),
      'revision' => t('Create new revision'),
    ),
    '#description' => t('Required field'),
  );

  $form['yourdob'] = array(
    '#type' => 'date',
    '#title' => t('DOB'),
    '#required' => TRUE,
    '#description' => t('Required field'),
  );

  $form['yourcv'] = array(
    '#type' => 'file',
    '#title' => t('Attach new file'),
    '#size' => 40,
    '#required' => TRUE,
    '#description' => t('Required field'),
  );

  $form['pass'] = array(
    '#type' => 'password',
    '#title' => t('Password'),
    '#maxlength' => 20,
    '#size' => 25,
    '#required' => TRUE,
    '#description' => t('Required field, max length 20 characters.'),
  );

  $form['posting_settings'] = array(
    '#type' => 'radios',
    '#title' => t('Preview comment'),
    '#options' => array(t('Optional'), t('Required')),
    '#required' => TRUE,
    '#description' => t('Required field'),
  );

  $form['feed'] = array(
    '#type' => 'select',
    '#title' => t('Display of XML feed items'),
    '#required' => TRUE,
    '#options' => array(
      '' => t('--select--'),
      'title' => t('Titles only'),
      'teaser' => t('Titles plus teaser'),
      'fulltext' => t('Full text'),
    ),
    '#description' => t('Required field'),
  );

  $form['feed2'] = array(
    '#type' => 'select',
    '#title' => t('Multiple items'),
    '#multiple' => 3,
    '#required' => TRUE,
    '#options' => array(
      '' => t('--select--'),
      'title' => t('Titles only'),
      'teaser' => t('Titles plus teaser'),
      'fulltext' => t('Full text'),
    ),
    '#description' => t('Required field'),
    '#minlength' => 2,
    '#maxlength' => 3,
  );

  $form['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Body'),
    '#required' => TRUE,
    '#maxlength' => 50,
    '#description' => t('Required field, max length 50 characters.'),
  );
  
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
    '#weight' => 100
  );

  return $form;
}
attiks’s picture

You don't have to change anything in your theme, if you enable the module it will add the js if needed

mdshields’s picture

This is great help. thank you very much for the feedback!

cjscullyca’s picture

Issue tags: +validation rules

Back to the original question and reply. If I set validation rules using the Webform Validate module, will those be translated from PHP to their Javascript counterparts? For example a rule that requires a numeric field to be between 0 and 100?

attiks’s picture

It should be, we support most of the validation rules provided by webform_validation

tungpham42’s picture

I wonder how to modify the error messages so that they are more specific rather than a generic message such as "This field is required". This is the case in my webforms.

attiks’s picture

The code uses the format "field label" is required

attiks’s picture

Status: Active » Fixed

closing this for now, if you need more information on how to use this, feel free to open a new issue

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jelle_s’s picture

A documentation page was created for Clientside Validation.