Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate 2.0.0 #42

Open
wants to merge 191 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
191 commits
Select commit Hold shift + click to select a range
c6b3bb9
Removed the quotes of selectors
Feb 1, 2013
daaec2e
fix typo in variable name
marmotz Feb 3, 2013
05075f2
fix documentation for validateSetup method
marmotz Feb 3, 2013
f24c0e5
#7 Added the valid and invalid events
Feb 4, 2013
55ba42f
Merge pull request #22 from marmotz/master
Feb 4, 2013
0188026
Update nameSpace to namespace
Feb 5, 2013
df1cc05
Added /* http://plugins.jquery.com/validate */
Feb 5, 2013
c3cc1fe
Corrected sendInvalidForm param
Feb 5, 2013
6546933
Added the sendInvalidForm param on documentation
Feb 5, 2013
d4c2e77
Created a data variable
Feb 5, 2013
9f671aa
#2 Use JSHint
Feb 5, 2013
6585315
#13 Validation groups
Feb 5, 2013
dcf506b
Corrections
Feb 7, 2013
6343d09
#10 Added the attribute
Feb 8, 2013
d2f06af
#2 Corrected all warnings
Feb 8, 2013
480b746
Working on the minlenbgth and maxlength attributes
Feb 8, 2013
a16eac1
Workin on minlength and maxlength attributes
Feb 10, 2013
228b011
#10 Worging in the data-minlength and data-maxlength attributes
Feb 13, 2013
1ce8ab1
#10 Working on the implementation of the data-minlength and data-maxl…
Feb 19, 2013
ea0a7fa
#28 Creating development branch
Mar 14, 2013
dbe714d
#28 Creating development branch
Mar 14, 2013
98a10c9
#27 Workin on the new structure
Mar 14, 2013
d2b24c0
#27 Reformulating the new README.md
Mar 14, 2013
80862de
#27 Reformulating the new README.md
Mar 14, 2013
0dda5ba
#27 Reformulating the new README.md
Mar 14, 2013
d4d2997
#27 Reformulating the new README.md
Mar 14, 2013
5c6c46a
#27 Correction in README.md
Mar 14, 2013
7538936
#27 Reformulating the new README.md
Mar 14, 2013
a2b9bca
#27 Reformulating the new README.md
Mar 15, 2013
7ad24b4
#27 Reformulating the new README.md
Mar 15, 2013
eb7706b
#27 Reformulating the new README.md
Mar 15, 2013
78f6bd1
#24 Added the grunt files.
Mar 19, 2013
446b4c3
Corrections
Mar 19, 2013
36dac81
#29 Added the jQuery.validate.on method
Mar 20, 2013
49ba004
Working on the new version
Mar 26, 2013
3bed0bb
Removed the global events
Mar 27, 2013
d112f38
Update README.md
Apr 1, 2013
bc1a24c
Added some custom events
Apr 2, 2013
f1da3f3
Added the counter method
Apr 2, 2013
2a956ca
Working on the counter method
Apr 3, 2013
c20df08
Update README.md
Apr 3, 2013
8dc3b2d
Update Gruntfile.js
Apr 3, 2013
c1f0e35
Correction in the pattern status
Apr 4, 2013
2f89819
Correction in the counter method and in the pattern status
Apr 4, 2013
9a387fe
Added validate selector
Apr 4, 2013
323f9bb
Update validate selector
Apr 5, 2013
476c47c
Update README.md
Apr 5, 2013
2236df6
Corrections
Apr 5, 2013
5e7fc54
Update README.md
Apr 5, 2013
60d15fa
Update README.md
Apr 5, 2013
7811af0
Update README.md
Apr 5, 2013
0b7105a
Update README.md
Apr 5, 2013
13e9551
Update Gruntfile.js
Apr 5, 2013
3c31d88
Corrections
Apr 9, 2013
af03d50
Corrections
Apr 9, 2013
a26e703
Correction on the fields validation
Apr 11, 2013
350f68f
Correction on the method to trigger validation
Apr 11, 2013
ce37d2e
Update README.md
Apr 11, 2013
146120b
Corrections
Apr 11, 2013
6fc2931
Corrections
Apr 11, 2013
bdc267f
Update README.md
Apr 12, 2013
42b728d
Added prepare functions
Apr 12, 2013
88758dd
Update README.md
Apr 12, 2013
6fd1414
Corrections
Apr 17, 2013
cd10621
#13 Created validation groups feature
Apr 19, 2013
6cdf1a9
Added selectFirstInvalid property
Apr 23, 2013
f161bea
Added valueHook property
Apr 23, 2013
9557eec
Update README.md
Apr 23, 2013
b3d4f53
Update Gruntfile.js
Apr 23, 2013
f3a27be
Corrections
Apr 23, 2013
0b79d21
Update README.md
Apr 24, 2013
ba44f6d
Correction in the field pattern
Apr 24, 2013
ff66d05
Correction on the field masks
Apr 24, 2013
5aa6ea5
Update README.md
Apr 24, 2013
d8dba8c
Fields mask
Apr 24, 2013
23588a2
Corrections
Apr 25, 2013
3fcc47d
Corrections
Apr 26, 2013
2fd67fe
Descriptions
Apr 26, 2013
f6b8944
Changed trigger method to triggerHandler in the custom events
Apr 29, 2013
16fa234
Added a clause option to verify the form before send
Apr 29, 2013
1b8dd3b
Added isValid method
Apr 29, 2013
83dd5f2
Corrections to create isValid method
Apr 30, 2013
137a042
Update JSHint options
Apr 30, 2013
fc13f8e
Update Gruntfile.js
Apr 30, 2013
02a10e9
Corrections
Apr 30, 2013
fee4680
Corrected and renamed isValid method
May 2, 2013
354af56
Field descriptions
May 2, 2013
f648616
Fields descriptions
May 3, 2013
8a2c7de
Fields descriptions
May 3, 2013
760a297
Update README.md
May 3, 2013
e93f946
Corrections on fields descriptions
May 3, 2013
784662a
Corrections
May 6, 2013
ea54ed8
Correction in the fields selector
May 7, 2013
b4e52de
Corrections
May 9, 2013
330cfac
Corrections
May 9, 2013
12d73ca
Corrections
May 10, 2013
6655d62
Update JSHint task
May 13, 2013
75f4cdb
Corrections
May 13, 2013
3af6941
data-chars attribute
May 14, 2013
7bc0320
Update README.md
May 16, 2013
14b1ce8
Corrections
May 16, 2013
bb48bda
Corrections
May 16, 2013
d7ecd7e
Corrections
May 16, 2013
4369ade
Changed jQuery.ifFunction to jQuery.isFunction
May 16, 2013
fa898dc
Decreasing the file size
May 17, 2013
782ceca
Changes
May 20, 2013
4d71dbd
Decreasing file size
May 21, 2013
c7f7eea
Update README.md
May 22, 2013
679ae78
Update README.md
May 22, 2013
94a7d9e
Changes in the plugin core
May 27, 2013
727dc7e
Remaking the core.
May 29, 2013
0198805
Update README.md
May 29, 2013
54cb49b
Added test files
May 29, 2013
20c7629
Added test files
May 29, 2013
ada4656
Corrections and enhancement on the core
Jun 3, 2013
4ef0694
Removed switch and created the attributes object with all prepares
Jun 4, 2013
901659c
selectFirstInvalid and clearInvalidFields attributes
Jun 4, 2013
de2f34f
Update README.md
Jun 5, 2013
ee9a3e5
Corrections
Jun 5, 2013
73029eb
Added travis file
Jun 5, 2013
2b3b4ef
Update travis file
Jun 5, 2013
53f9adc
Update README.md
Jun 5, 2013
bbe2215
Update README.md
Jun 5, 2013
d15a82f
Corretion on the travis file
Jun 5, 2013
5b60c51
Update travis file
Jun 6, 2013
a9bd973
Update README.md
Jun 6, 2013
2b29022
Corrections on jQuery.fn.validate('valid') method
Jun 7, 2013
2e4d975
Decreasing code
Jun 7, 2013
80bf7fe
Update README.md
Jun 13, 2013
a314ad2
Corrections
Jun 13, 2013
bda2398
Added event.stopImmediatePropagation(); when validation is failed.
Jun 14, 2013
7d53406
Update README.md
Jun 18, 2013
a74dd5f
Lisence corrected
Jun 25, 2013
faab27d
Updade README.md
Jun 28, 2013
ed586d7
Update version number
Jun 28, 2013
256a7ed
Update README.md
Jul 5, 2013
02a2ab0
Implemented QUnit
Jul 12, 2013
9991388
Correcting Travis error
Jul 12, 2013
2e7fcbb
Fields descriptions
Jul 12, 2013
59ce2ce
Corrections on validate.js file and started tests creation
Jul 24, 2013
d3b3e1c
Corrections
Aug 2, 2013
b200000
Corrections on initialization of plugin
Aug 5, 2013
298c7c2
Update license
Aug 6, 2013
6e7fd1e
Correction on code indentation
Aug 9, 2013
1fdcc26
Added ajax options
Aug 12, 2013
ffe575c
Correction
Aug 13, 2013
1cd4546
Correction on conditional feature
Aug 14, 2013
1cd178f
Correction
Aug 14, 2013
540c199
Added sublime snippet
Aug 14, 2013
be1f559
Update snippet
Aug 14, 2013
758e56c
Added bower.json
Aug 15, 2013
68807f1
Added .gitignore
Aug 15, 2013
270cdac
Update JSHint options
Aug 15, 2013
cfef3fb
Enhancements
Aug 26, 2013
abd4f68
Enhancements
Aug 26, 2013
4114745
Enhancements
Aug 28, 2013
a6c688d
Changes in options
Sep 2, 2013
2c4e026
Enhancements
Sep 9, 2013
00aeb6d
Enhancements
Sep 16, 2013
c9cf7d8
Commentaries
Sep 16, 2013
5a3444a
Corrections
Sep 24, 2013
2c2104c
Correction of return for chaining.
Sep 25, 2013
9e2ada7
Added a method to trigger validation
Sep 25, 2013
6af59e9
Correction
Sep 25, 2013
de89dd9
Enhancements
Sep 25, 2013
da8d86c
Created a function to change the form options
Sep 25, 2013
e11157d
Enhancements and tests
Sep 26, 2013
a02cda3
Enhancements
Oct 9, 2013
d5054ad
Enhancements
Oct 11, 2013
baab2e0
Enhancements
Oct 15, 2013
53b806b
Enhancements
Oct 31, 2013
13913ae
Correction to get the field values
Nov 5, 2013
060a0c5
Correction on callbacks
Nov 7, 2013
26e3b30
Enhancements
Nov 11, 2013
f9bc1b8
Enhancements
Nov 11, 2013
c9bb588
Enhancements
Nov 11, 2013
98e5842
Removed default validations
Nov 20, 2013
6796ca4
Correction
Nov 20, 2013
e15ba33
Correction
Nov 20, 2013
99762e1
Correction on scroll parameter
Nov 22, 2013
e08435c
Enhancements
Nov 26, 2013
0aa9723
Corrections
Dec 6, 2013
25df53b
Enhancements
Dec 6, 2013
70c4196
Added custom selectors
Dec 13, 2013
14503f4
Initialization of custom selectors
Dec 19, 2013
b9eb36d
Correction on trigger validation
Jan 16, 2014
4785c06
Correction on trigger and is valid methods
Jan 17, 2014
7748088
Enhancement
Mar 14, 2014
be32da1
Added coverage badge
Mar 26, 2014
22b332e
Enhacements
Mar 28, 2014
9cc1645
Correction in the data-char attribute
Apr 11, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
19 changes: 19 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"camelcase" : true,
"immed" : true,
"indent" : true,
"latedef" : true,
"newcap" : true,
"noarg" : true,
"noempty" : true,
"quotmark" : true,
"undef" : true,
"unused" : true,
"strict" : true,
"trailing" : true,
"browser": true,
"globals" : {
"jQuery" : true,
"Event" : true
}
}
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli bower
58 changes: 58 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module.exports = function(grunt) {

'use strict';

var

packageFile = 'package.json',

data = grunt.file.readJSON(packageFile),

uglifyFiles = {};

uglifyFiles[data.name + '.min.js'] = data.name + '.js';

grunt.config.init({
uglify : {
dist : {
files : uglifyFiles,
options : {
banner : '/*! jQuery Validate ' + data.version + ' | http://plugins.jquery.com/' + data.name + '/' + data.version + ' */\n;'
}
}
},
jshint : {
dist : {
src : [data.name + '.js'],
options : {
jshintrc : '.jshintrc'
}
}
},
qunit : {
dist : {
options : {
timeout : 999999,
urls : [data.name + '.test.html']
}
}
},
watch : {
dist : {
files : [data.name + '.js', packageFile],
tasks : ['uglify:dist', 'jshint:dist', 'qunit:dist']
}
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.loadNpmTasks('grunt-contrib-jshint');

grunt.loadNpmTasks('grunt-contrib-qunit');

grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['uglify:dist', 'jshint:dist', 'qunit:dist']);

};
306 changes: 7 additions & 299 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,304 +1,12 @@
# jQuery Validate
# Validate <a rel="license" href="http://creativecommons.org/licenses/by/3.0/" target="_blank" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/80x15.png" /></a>

> License: <a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">_MIT_</a>.
[![Build Status](https://travis-ci.org/DiegoLopesLima/Validate.png)](https://travis-ci.org/DiegoLopesLima/Validate)
[![Coverage Status](https://coveralls.io/repos/DiegoLopesLima/Validate/badge.png)](https://coveralls.io/r/DiegoLopesLima/Validate)

> Version: _1.1.2_.
> License: <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Validate</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.

> Requires: _jQuery 1.7+_.
> Version: 2.0.0

To use _jQuery Validate_ you just need to include in your code a version of the <a href="http://jquery.com/" target="_blank">jQuery library</a> equal or more recent than `1.7` and a file with the plugin. <a href="https://www.dropbox.com/s/p5xhpb52572xy5b/jQuery%20Validate%201.1.2.zip" target="_blank">Click here to download the plugin</a>.
> Requires: jQuery 1.7+

After this, you just need select your form and calling the `jQuery.fn.validate` method.

See a example:
```javascript
jQuery('form').validate();
```

After calling the `jQuery.fn.validate` method, you can validate your fields using <a href="http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes" target="_blank">data attributes</a>, that are valid to the <a href="http://www.w3.org/TR/html5/" target="_blank">HTML5</a>, according to the <a href="http://www.w3.org/" target="_blank">W3C</a>.

See a example to required field:
```html
<form>
<input type="text" data-required />
</form>
```

_jQuery Validate_ supports all fields of the HTML5 and uses <a href="http://www.w3.org/WAI/PF/aria/" target="_blank">WAI-ARIA</a> for accessibility. You can use several attributes to your validations.

## Attributes

<table>
<tr>
<th width="110px">Attribute</th>

<th>Description</th>

<th width="75px">Default</th>
</tr>

<tr>
<td>data-conditional</td>

<td>Accepts one or more indexes separated by spaces from the `conditional` object that should contain a the boolean return function.</td>

<td></td>
</tr>

<tr>
<td>data-ignore-case</td>

<td>Accepts a boolean value to specify if field is case-insensitive.</td>

<td>true</td>
</tr>

<tr>
<td>data-mask</td>

<td>Accepts a mask to change the field value to the specified format. The mask should use the character groups of the regular expression passed to the <a href="#data-pattern">`data-pattern`</a> attribute.</td>

<td>${0}</td>
</tr>

<tr>
<td>data-pattern</td>

<td>Accepts a regular expression to test the field value.</td>

<td>/(?:)/</td>
</tr>

<tr>
<td>data-prepare</td>

<td>Accepts a index from the `prepare` object that should contain a function to receive the field value and returns a new value treated.</td>

<td></td>
</tr>

<tr>
<td>data-required</td>

<td>Accepts a boolean value to specify if field is required.</td>

<td>false</td>
</tr>

<tr>
<td>data-trim</td>

<td>Accepts a boolean value. If true, removes the spaces from the ends in the field value. (The field value is not changed)</td>

<td>false</td>
</tr>

<tr>
<td>data-validate</td>

<td>You can use the `data-validate` to calling extensions.</td>

<td></td>
</tr>
</table>

## Parameters

<table>
<tr>
<th width="110px">Parameter</th>

<th>Description</th>

<th width="75px">Default</th>
</tr>

<tr>
<td>conditional</td>

<td>Accepts a object to store functions from validation.</td>

<td></td>
</tr>

<tr>
<td>filter</td>

<td>Accepts a selector string or function to filter the validated fields.</td>

<td>*</td>
</tr>

<tr>
<td>nameSpace</td>

<td>A namespace used in all delegates events.</td>

<td>validate</td>
</tr>

<tr>
<td>onBlur</td>

<td>Accepts a boolean value. If true, triggers the validation when blur the field.</td>

<td>false</td>
</tr>

<tr>
<td>onChange</td>

<td>Accepts a boolean value. If true, triggers the validation when change the field value.</td>

<td>false</td>
</tr>

<tr>
<td>onKeyup</td>

<td>Accepts a boolean value. If true, triggers the validation when press any key.</td>

<td>false</td>
</tr>

<tr>
<td>onSubmit</td>

<td>Accepts a boolean value. If true, triggers the validation when submit the form.</td>

<td>true</td>
</tr>

<tr>
<td>prepare</td>

<td>Accepts a object to store functions to prepare the field values.</td>

<td></td>
</tr>

<tr>
<td>sendForm</td>

<td>Accepts a boolean value. If false, prevents submit the form (Useful to submit forms via <a href="http://api.jquery.com/jQuery.ajax/" target="_blank">AJAX</a>).</td>

<td>true</td>
</tr>

<tr>
<td>waiAria</td>

<td>Accepts a boolean value. If false, disables <a href="http://www.w3.org/WAI/PF/aria/" target="_blank">WAI-ARIA</a>.</td>

<td>true</td>
</tr>
</table>

## Callbacks

<table>
<tr>
<th width="110px">Callback</th>

<th>Description</th>
</tr>

<tr>
<td>valid</td>

<td>Accepts a function to be calling when form is valid. The context (`this`) is the current verified form and the parameters are respectively `event` and `options`.</td>
</tr>

<tr>
<td>invalid</td>

<td>Accepts a function to be calling when form is invalid. The context (`this`) is the current verified form and the parameters are respectively `event` and `options`.</td>
</tr>

<tr>
<td>eachField</td>

<td>Accepts a function to be calling to each field. The context (`this`) is the current verified field and the parameters are respectively `event`, `status` and `options`.</td>
</tr>

<tr>
<td>eachInvalidField</td>

<td>Accepts a function to be calling when field is invalid. The context (`this`) is the current verified field and the parameters are respectively `event`, `status` and `options`.</td>
</tr>

<tr>
<td>eachValidField</td>

<td>Accepts a function to be calling when field is valid. The context (`this`) is the current verified field and the parameters are respectively `event`, `status` and `options`.</td>
</tr>
</table>

## Removing validation
You can remove validation of a form using the `jQuery.fn.validateDestroy` method.

Example:
```javascript
jQuery('form').validateDestroy();
```

## Changing the default values of `jQuery.fn.validate`
You can changes the default values of `jQuery.fn.validate` using `jQuery.validateSetup` method.

Example:
```javascript
jQuery('form').validateSetup({
sendForm : false,
onKeyup : true
});
```

## Creating descriptions
You can create descriptions to the field states.

Example:
```html
<form>
<input type="text" data-describedby="messages" data-description="test" />

<span id="messages"></span>
</form>
```

```javascript
$('form').validate({
description : {
test : {
required : '<div class="error">Required</div>',
pattern : '<div class="error">Pattern</div>',
conditional : '<div class="error">Conditional</div>',
valid : '<div class="success">Valid</div>'
}
}
});
```

## Creating extensions
You can use the `jQuery.validateExtend` method to extend the validations and calling the extensions with `data-validate` attribute.

Example:
```html
<form>
<input type="text" name="age" data-validate="age" />
</form>
```

```javascript
jQuery('form').validate();

jQuery.validateExtend({
age : {
required : true,
pattern : /^[0-9]+$/,
conditional : function(value) {

return Number(value) > 17;
}
}
});
```
> Author: [Diego Lopes Lima](https://github.com/DiegoLopesLima)
Loading