Skip to content

Commit 0e0a577

Browse files
committed
Merge pull request #1 from victorjonsson/master
fetching changes
2 parents 3121e62 + 9141054 commit 0e0a577

39 files changed

+3133
-1930
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
.idea/

README.md

Lines changed: 46 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ it's designed to require as little bandwidth as possible. This is achieved by gr
66
in "modules", making it possible for the programmer to load **only those functions that's needed** to validate a
77
particular form.
88

9-
**Form demos and full documentation is available at http://formvalidator.net/**
9+
**Form demos and full documentation available at http://formvalidator.net/**
1010

1111
*Usage example*
1212

@@ -38,24 +38,22 @@ particular form.
3838
</script>
3939
```
4040

41-
### Moving up to version 2.0
41+
### Support for HTML5
4242

43-
So what has changed since version 1.x?
43+
As of version 2.2 (unreleased) you can use this plugin as a fallback solution for the validation attributes in the HTML5 spec. Add the module `html5` to the module declaration and you can use the following native features:
44+
45+
**Attributes**: require, pattern, maxlength, min, max, placeholder
46+
47+
**Input types**: url, date, time, email, number
48+
49+
**Elements**: Use the element `datalist` to create input suggestions
4450

45-
* A whole bunch of validation functions have been added (see below).
46-
* A modular design have been introduced, which means that some validation functions is default and others is
47-
part of a module. This in turn lowers server and bandwidth costs.
48-
* You no longer need to prefix the validation rules with "validate_".
49-
* Error message position now defaults to "element".
50-
* The optional features (validateOnBlur and showHelpOnFocus) is now enabled by default.
51-
* The function $.validate(config) is introduced to reduce the amount of code that has to be written when initiating the form validation.
52-
* Demos and full documentation is now available at http://formvalidator.net/
5351

5452
### Default validators and features (no module needed)
5553
* **url**
5654
* **email**
5755
* **domain***domain.com*
58-
* **number***float/negative/positive/range*
56+
* **number***float/negative/positive/range/step*
5957
* **date***yyyy-mm-dd (format can be customized, more information below)*
6058
* **alphanumeric***with support for defining additional characters*
6159
* **length***min/max/range*
@@ -69,14 +67,18 @@ So what has changed since version 1.x?
6967
* Make validation dependent on another input of type checkbox being checked by adding attribute
7068
data-validation-if-checked="name of checkbox input"
7169
* Create input suggestions with ease, no jquery-ui needed
70+
* to apply multiple validators to an input element, separate the validator names using a space (ex: required email)
7271

7372
Read the documentation for the default features at [http://formvalidator.net/#default-validators](http://formvalidator.net/#default-validators)
7473

7574
### Module: security
7675
* **spamcheck**
7776
* **confirmation**
78-
* **strength***Validate the strength of a password (strength strength3)*
79-
* **backend***Validate value of input on server side*
77+
* **creditcard**
78+
* **CVV**
79+
* **strength***Validate the strength of a password*
80+
* **server***Validate value of input on server side*
81+
* **letternumeric***Validate that the input value consists out of only letters and/or numbers*
8082

8183
Read the documentation for the security module at [http://formvalidator.net/#security-validators](http://formvalidator.net/#security-validators)
8284

@@ -98,7 +100,8 @@ Read the documentation for the location module at [http://formvalidator.net/#loc
98100
### Module: file
99101
* **mime**
100102
* **extension**
101-
* **size**
103+
* **size** (file size)
104+
* **dimension** ()
102105

103106
Read the documentation for the file module at [http://formvalidator.net/#file-validators](http://formvalidator.net/#file-validators)
104107

@@ -214,74 +217,13 @@ It is possible to display help information for each input. The information will
214217

215218
Read about how to customize this plugin over at [http://formvalidator.net/#configuration](http://formvalidator.net/#configuration)
216219

217-
## Localization
218-
This plugin contains a set of error dialogs. In case you don't define an inline error message the plugin
219-
will fall back on one of the dialogs below. You can how ever add the attribute *data-validation-error-msg* to an
220-
element, and that message will be displayed instead. All error dialogs can be overwritten by passing an
221-
object into the validation function.
222-
223-
```javascript
224-
var enErrorDialogs = {
225-
errorTitle : 'Form submission failed!',
226-
requiredFields : 'You have not answered all required fields',
227-
badTime : 'You have not given a correct time',
228-
badEmail : 'You have not given a correct e-mail address',
229-
badTelephone : 'You have not given a correct phone number',
230-
badSecurityAnswer : 'You have not given a correct answer to the security question',
231-
badDate : 'You have not given a correct date',
232-
lengthBadStart : 'You must give an answer between ',
233-
lengthBadEnd : 'characters',
234-
lengthTooLongStart : 'You have given an answer longer than ',
235-
lengthTooShortStart : 'You have given an answer shorter than ',
236-
notConfirmed : 'Values could not be confirmed',
237-
badDomain : 'Incorrect domain value',
238-
badUrl : 'The answer you gave was not a correct URL',
239-
badCustomVal : 'You gave an incorrect answer',
240-
badInt : 'The answer you gave was not a correct number',
241-
badSecurityNumber : 'Your social security number was incorrect',
242-
badUKVatAnswer : 'Incorrect UK VAT Number',
243-
badStrength : 'The password isn\'t strong enough',
244-
badNumberOfSelectedOptionsStart : 'You have to choose at least ',
245-
badNumberOfSelectedOptionsEnd : ' answers',
246-
badAlphaNumeric : 'The answer you gave must contain only alphanumeric characters ',
247-
badAlphaNumericExtra: ' and ',
248-
wrongFileSize : 'The file you are trying to upload is too large',
249-
wrongFileType : 'The file you are trying to upload is of wrong type',
250-
groupCheckedTooFewStart : 'Please choose at least ',
251-
groupCheckedTooManyStart : 'Please choose a maximum of ',
252-
groupCheckedRangeStart : 'Please choose between ',
253-
groupCheckedEnd : ' item(s)'
254-
};
255-
```
256-
257-
```html
258-
<form action="script.php">
259-
...
260-
</form>
261-
<script src="js/jquery.min.js"></script>
262-
<script src="js/form-validator/jquery.form-validator.min.js"></script>
263-
<script src="js/form-validator/locale.en.js"></script>
264-
<script>
265-
$.validate({
266-
language : enErrorDialogs
267-
});
268-
</script>
269-
...
270-
```
220+
### Validate On Event ###
221+
You can cause an element to be validated upon the firing of an event, by attaching an attribute to the form input element named `data-validation-event="click"`. When the configuration settings have `validateOnEvent : true`, the click event will trigger the onBlur validaton for that element. Possible use case: Checkboxes. Instead of waiting for the checkbox to lose focus (blur) and waiting for a validation to occurr, you can specify that elements validation should occur as soon as that checkbox element is clicked.
271222

272-
It's also possible to add inline error messages. If you add attribute `data-validation-error-msg` to an element the value of
273-
that attribute will be displayed instead of the error dialog that the validation function refers to.
223+
## Localization
274224

275-
## Input length restriction
276-
```html
277-
<p>
278-
History (<span id="maxlength">50</span> characters left)
279-
<textarea rows="3" id="area"></textarea>
280-
</p>
281-
<script type="text/javascript">
282-
$('#area').restrictLength( $('#maxlength') );
283-
</script>
284-
```
225+
This plugin comes with translations for English, German, French Spanish and Swedish. You can also choose to override the error
226+
dialogs yourself. Here you can read more about [localization](http://formvalidator.net/#localization)
285227

286228
## Program Flow
287229
Form submit() event is bound to jQ func **validateForm()** when the form is submitted, it calls
@@ -294,15 +236,35 @@ it calls jQ func **$.formUtils.validateInput** to validate the single input when
294236

295237
## Changelog
296238

297-
#### 2.2.0 (unreleased)
239+
240+
#### 2.2.43
241+
- Fixed min/max parse error in HTML5 module
242+
- Now also supports Twitter bootstraps horizontal forms
243+
- This plugin now also distributes a default CSS theme including success/fail icons (used on formvalidator.net)
244+
- Email validation now won't fail if email begins with a number
245+
- This plugin now comes with error dialogs translated to English, French, German, Spanish and English.
246+
- New validator `letternumeric`. Validates that input consists out of any type of letter (not only alphanumeric) and/or numbers
247+
- You can now validate image dimension and ratio
248+
- ... and a bunch of other smaller bug fixes and improvements.
249+
250+
#### 2.2.0
298251
* Now possible to define an error message for each validation rule on a certain input (issue #113)
299252
* This plugin now serves as a html5 fallback. You can now use the native attributes to declare which type
300253
of validation that should be applied.
301254
* Use a template for error messages when having errorMessagePosition set to top
255+
* Added validation of credit card number and CVV to the security module
302256
* Event onElementValidate added
303257
* Use the attribute data-validation-confirm to declare which input that should be confirmed when using validation=confirmation (issue #112)
304258
* Validation "required" now supports inputs of type radio
305-
259+
* $.validateForm is now deprecated, use $.isValid instead
260+
* Possible to check if form is valid programmatically without showing error messages
261+
* Select elements can now be validated server-side
262+
* Cleaned up dialog messages
263+
* Various IE8 fixes
264+
* Possible to send along parameters to the server when using server side validation
265+
* Now possible to set your own parameter name when using server side validation
266+
* Improved/simplified URL validation
267+
* ... and a whole lot more small improvements
306268

307269
#### 2.1.47
308270
* Incorrect error-styling when using datepicker or suggestions is now fixed
@@ -342,7 +304,7 @@ calling $.validate()
342304
the $.validationSetup but it's considered deprecated.
343305

344306
#### 2.1.6
345-
* Modules can now be loaded from remote website
307+
* Modules can now be loaded from remote websites
346308

347309
#### 2.1.5
348310
* Fixed language bug (issue #43 on github)

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "jQuery-Form-Validator",
3-
"version": "2.1.47",
3+
"version": "2.2.43",
44
"homepage": "http://formvalidator.net/",
55
"authors": [
66
"victorjonsson"
77
],
88
"description": "With this feature rich jQuery plugin it becomes easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's designed to require as little bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
9-
"main": "jquery.form-validator.min.js",
9+
"main": "./form-validator/jquery.form-validator.min.js",
1010
"keywords": [
1111
"form",
1212
"validator",

build

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ var fs = require('fs'),
88
mainMinifiedScript = jsPath + 'jquery.form-validator.min.js',
99
newVersion = -1;
1010

11-
/*
12-
* Find out new version number
13-
*/
11+
// Find out new version number
1412
var versionParts = fs.readFileSync(mainScript, 'utf-8').split('@version ')[1].split('*/')[0].trim().split('.');
1513
if(versionParts.length < 3) {
1614
// new version number is decided in code
@@ -24,47 +22,56 @@ else {
2422

2523
console.log('Build version: '+newVersion);
2624

27-
/*
28-
* Get code docs
29-
*/
25+
// Get code docs
3026
var documentation = fs.readFileSync(mainScript, 'utf-8').split('*/')[0]+'*/';
3127
var docParts = documentation.split('@version ');
3228
documentation = docParts[0] +'@version '+newVersion+'\n'+docParts[1].split('\n')[1];
3329

3430

3531
/**
36-
* Create new minified version of a file and change
37-
* version number
38-
* @param {String} path
39-
* @param {String} newName
32+
* Create new minified version of a file and change version number
33+
* @param {String} sourceFile
34+
* @param {String} targetFile
35+
* @param {String} [bin]
4036
*/
41-
function buildFile(path, newName) {
42-
var codeParts = fs.readFileSync(path, 'utf-8').split('@version ');
43-
var lastCodeParts = codeParts[1].split("\n");
44-
var origCode = codeParts[0] + '@version '+newVersion+ "\n" + lastCodeParts.slice(1, lastCodeParts.length).join("\n") + "";
45-
fs.writeFileSync(path, origCode);
46-
fs.writeFileSync(newName, '');
47-
exec('uglifyjs '+path+' >> '+newName, function (error, stdout, stderr) {
37+
function buildFile(sourceFile, targetFile, bin) {
38+
var codeParts = fs.readFileSync(sourceFile, 'utf-8').split('@version '),
39+
lastCodeParts = codeParts[1].split("\n"),
40+
origCode = codeParts[0] + '@version '+newVersion+ "\n" + lastCodeParts.slice(1, lastCodeParts.length).join("\n") + "";
41+
42+
fs.writeFileSync(sourceFile, origCode);
43+
fs.writeFileSync(targetFile, '');
44+
45+
if(!bin)
46+
bin = 'uglifyjs %source% >> %target%';
47+
48+
exec(bin.replace('%source%', sourceFile).replace('%target%', targetFile), function (error, stdout, stderr) {
4849
if(stdout)
4950
console.log('stdout: '+stdout);
5051
if(error)
5152
console.log('error: '+error);
5253
if(stderr)
5354
console.log('stderror: '+stderr);
5455

55-
console.log('* '+newName);
56+
console.log('* '+targetFile);
5657
});
5758
}
5859

60+
// Minify main script
5961
buildFile(mainScript, mainMinifiedScript);
60-
fs.readdirSync(jsPath).forEach(function(f) {
61-
if(f.substr(-7) == '.dev.js') {
62-
var compressedFileName = jsPath + f.substr(0, f.length - 6) + 'js';
63-
buildFile(jsPath+f, compressedFileName);
62+
63+
// Put top documentation back into minified main script
64+
fs.writeFileSync(mainMinifiedScript, documentation+"\n"+fs.readFileSync(mainMinifiedScript, 'utf-8'));
65+
66+
// Minify modules and language files
67+
[jsPath, jsPath+'lang/'].forEach(function(path) {
68+
fs.readdirSync(path).forEach(function(fileName) {
69+
if(fileName.substr(-7) == '.dev.js') {
70+
var compressedFileName = path + fileName.substr(0, fileName.length - 6) + 'js';
71+
buildFile(path+fileName, compressedFileName);
6472
}
73+
});
6574
});
6675

67-
/*
68-
* Add docs to main script
69-
*/
70-
fs.writeFileSync(mainMinifiedScript, documentation+"\n"+fs.readFileSync(mainMinifiedScript, 'utf-8'));
76+
// Minify default theme css
77+
buildFile(jsPath+'theme-default.css', jsPath+'theme-default.min.css', 'sqwish %source%');

form-validator/date.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.56
13+
* @version 2.2.43
1414
*/
1515
(function($) {
1616

form-validator/date.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)