https://github.com/botto/parsley_js
Drupal module to integrate with parsley.js
https://github.com/botto/parsley_js
Last synced: 5 months ago
JSON representation
Drupal module to integrate with parsley.js
- Host: GitHub
- URL: https://github.com/botto/parsley_js
- Owner: botto
- Created: 2014-01-06T21:03:59.000Z (over 12 years ago)
- Default Branch: 7.x-1.x
- Last Pushed: 2014-12-06T17:11:40.000Z (over 11 years ago)
- Last Synced: 2025-06-04T10:02:06.263Z (about 1 year ago)
- Size: 340 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.txt
Awesome Lists containing this project
README
#parsley_js
Drupal module that provides integration with the client side validation library
parsley.js.
Currently this module only integrates on the FAPI layer.
At it's core it's simply injects the correct attributes into the relevant FAPI
field using hook_form_alter
It expects the same syntax as FAPI validation module using the rules attribute.
##Requirements
1. Libraries module
2. jQuery Update (Tested with jQuery 1.6, mileage may vary with earlier
versions of jQuery)
3. Parsley.js 1.2.4
##Installation
1. Download the parsley.js library
https://github.com/guillaumepotier/Parsley.js/archive/1.2.4.tar.gz to your
libraries location (usually sites/all/libraries)
2. Expand the contents of the archive in to parsleyjs, so that the folder
structure reads libraries/parsleyjs and parsley.js is directly under parsleyjs
folder
3. Enable the module under admin/modules
4. Set jQuery update to 1.9 or later under
admin/config/development/jquery_update
##Configuration
Currently there are no configuration options.
##Usage
To enable a form to be validated, simply set #parsley_js in the form array
to true.
```php
$form['#parsley_js'] = TRUE;
```
Set the #rules key on each field you want validated
```php
$form['my-field'] = array(
'#title' => t('My Field'),
'#description' => t("It's my field, only I get to fill it in"),
'#required' => TRUE,
'#rules' => array(
'length[3,10]',
'email',
),
;
```
###Rules
Currently only the following rules are implemented.
Where possible the rule names will follow the FAPI validation name, otherwise it
will have the same rule name as the parsley.js documentation
* notblank
* email
* url
* urlstrict
* digit
* numeric
* alpha_numeric
* date_iso
* phone
* length
* range
Details of these rules can be found at
https://parsleyjs.github.io/Parsley-1.x/documentation.html#validators
####Exceptions
**dateIso**:
Parsley.js calls it dateIso, use date_iso instead to keep consistency
**Length**:
The length rules supports both specific length, min length and max length.
A set length is indicated bu ```length[2,9]``` meaning any string
between 2 and 9 characters long
A min length is indicated by ```length[3, *]```
A max length is indicated by ```length[*, 6]```
**Range**:
The range follows the same syntax, except this checks the numeric length of the
value. ```range[3, 8]``` validates the input is between 3 and 8