Skip to content

Commit 7ca10b1

Browse files
committed
minor bug fixed, renamed functions in modules, closing up on version 2.1
1 parent db4ea23 commit 7ca10b1

16 files changed

+47
-46
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ if **validateOnBlur** = true, jQ finds all form input elements with the data-val
299299

300300
## Changelog
301301

302+
#### 2.1
303+
* Code refactoring and some functions renamed
304+
* Validator "checkbox_group" added
305+
302306
#### 2.0.7
303307
* Now possible to validate file size, extension and mime type (using the file module)
304308

@@ -320,8 +324,8 @@ if **validateOnBlur** = true, jQ finds all form input elements with the data-val
320324
[Victor Jonsson](https://github.com/victorjonsson)
321325

322326
#### Contributors
323-
<a href="https://github.com/robamaton" target="_blank">Joel Sutherland</a><br />
324327
<a href="http://stevewasiura.waztech.com" target="_blank">Steve Wasiura</a><br />
328+
<a href="https://github.com/robamaton" target="_blank">Joel Sutherland</a><br />
325329
<a href="https://github.com/mattclements" target="_blank">Matt Clements</a><br />
326330
<a href="https://github.com/dfcplc" target="_blank">@dfcplc</a><br />
327331
<a href="https://github.com/coffein" target="_blank">Andree Wendel</a><br />

form-validator/date.dev.js

Lines changed: 3 additions & 3 deletions
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.0.10
13+
* @version 2.0.12
1414
*/
1515
(function($) {
1616

@@ -19,7 +19,7 @@
1919
*/
2020
$.formUtils.addValidator({
2121
name : 'time',
22-
validate : function(time) {
22+
validatorFunction : function(time) {
2323
if (time.match(/^(\d{2}):(\d{2})$/) === null) {
2424
return false;
2525
} else {
@@ -40,7 +40,7 @@
4040
*/
4141
$.formUtils.addValidator({
4242
name : 'birthdate',
43-
validate : function(val, $el, conf) {
43+
validatorFunction : function(val, $el, conf) {
4444
var dateFormat = 'yyyy-mm-dd';
4545
if($el.valAttr('format')) {
4646
dateFormat = $el.valAttr('format');

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.

form-validator/file.dev.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.0.10
13+
* @version 2.0.12
1414
*/
1515
(function($, window) {
1616

@@ -34,7 +34,7 @@
3434
*/
3535
$.formUtils.addValidator({
3636
name : 'mime',
37-
validate : function(str, $input) {
37+
validatorFunction : function(str, $input) {
3838
var files = $input.get(0).files || [];
3939

4040
if( SUPPORTS_FILE_READER ) {
@@ -56,7 +56,7 @@
5656
return valid;
5757

5858
} else {
59-
return $.formUtils.validators.extension.validate(str, $input);
59+
return $.formUtils.validators.extension.validatorFunction(str, $input);
6060
}
6161
},
6262
errorMessage : 'The file you are trying to upload is of wrong type',
@@ -68,7 +68,7 @@
6868
*/
6969
$.formUtils.addValidator({
7070
name : 'extension',
71-
validate : function(val, $input) {
71+
validatorFunction : function(val, $input) {
7272
var ext = val.substr( val.lastIndexOf('.')+1 );
7373
return $.inArray(ext.toLowerCase(), _getTypes($input)) > -1;
7474
},
@@ -81,7 +81,7 @@
8181
*/
8282
$.formUtils.addValidator({
8383
name : 'size',
84-
validate : function(val, $input) {
84+
validatorFunction : function(val, $input) {
8585
var maxSize = $input.valAttr('max-size');
8686
if( !maxSize ) {
8787
console.log('Input "'+$input.attr('name')+'" is missing data-validation-max-size attribute');

form-validator/file.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.

form-validator/jquery.form-validator.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @website http://formvalidator.net/
77
* @license Dual licensed under the MIT or GPL Version 2 licenses
8-
* @version 2.0.10
8+
* @version 2.0.12
99
*/
1010
(function($) {
1111

@@ -387,7 +387,7 @@
387387
* Short hand function that makes the validation setup require less code
388388
* @param config
389389
*/
390-
$.validatorLoad = function(config) {
390+
$.setupForm = function(config) {
391391
config = $.extend({
392392
form : 'form',
393393
validateOnBlur : true,
@@ -1094,9 +1094,7 @@
10941094
groupCheckedRangeStart : 'Please choose between ',
10951095
groupCheckedTooFewStart : 'Please choose at least ',
10961096
groupCheckedTooManyStart : 'Please choose a maximum of ',
1097-
groupCheckedEnd : ' item(s)',
1098-
1099-
_dummy--last-item-placeholder-without-comma : 0
1097+
groupCheckedEnd : ' item(s)'
11001098
}
11011099
};
11021100

@@ -1242,12 +1240,13 @@
12421240
}
12431241

12441242
// check if length is above min, below max, within range etc.
1245-
var lengthCheckResults = $.formUtils.numericRangeCheck(value.length, lengthAllowed) ;
1243+
var lengthCheckResults = $.formUtils.numericRangeCheck(value.length, lengthAllowed),
1244+
checkResult;
12461245

12471246
switch(lengthCheckResults[0] )
12481247
{ // outside of allowed range
12491248
case "out":
1250-
this.errorMessage = lang.lengthBadStart + len + lang.lengthBadEnd;
1249+
this.errorMessage = lang.lengthBadStart + lengthAllowed + lang.lengthBadEnd;
12511250
checkResult = false;
12521251
break;
12531252
// too short
@@ -1385,15 +1384,14 @@
13851384
});
13861385

13871386

1388-
/*
1387+
/*
13891388
* Validate group of checkboxes, validate qty required is checked
13901389
* written by Steve Wasiura : http://stevewasiura.waztech.com
13911390
* element attrs
13921391
* data-validation="checkbox_group"
13931392
* data-validation-qty="1-2" // min 1 max 2
13941393
* data-validation-error-msg="chose min 1, max of 2 checkboxes"
13951394
*/
1396-
13971395
$.formUtils.addValidator({
13981396
name : 'checkbox_group',
13991397
validatorFunction : function(val, $el, config, lang, $form)
@@ -1439,6 +1437,5 @@
14391437
// errorMessage : '', // set above in switch statement
14401438
// errorMessageKey: '' // not used
14411439
});
1442-
14431440

14441441
})(jQuery);

form-validator/jquery.form-validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/location.dev.js

Lines changed: 4 additions & 4 deletions
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.0.10
13+
* @version 2.0.12
1414
*/
1515
(function($) {
1616

@@ -19,7 +19,7 @@
1919
*/
2020
$.formUtils.addValidator({
2121
name : 'country',
22-
validate : function(str) {
22+
validatorFunction : function(str) {
2323
return $.inArray(str.toLowerCase(), this.countries) > -1;
2424
},
2525
countries : ['afghanistan','albania','algeria','american samoa','andorra','angola','anguilla','antarctica','antigua and barbuda','arctic ocean','argentina','armenia','aruba','ashmore and cartier islands','atlantic ocean','australia','austria','azerbaijan','bahamas','bahrain','baltic sea','baker island','bangladesh','barbados','bassas da india','belarus','belgium','belize','benin','bermuda','bhutan','bolivia','borneo','bosnia and herzegovina','botswana','bouvet island','brazil','british virgin islands','brunei','bulgaria','burkina faso','burundi','cambodia','cameroon','canada','cape verde','cayman islands','central african republic','chad','chile','china','christmas island','clipperton island','cocos islands','colombia','comoros','cook islands','coral sea islands','costa rica','croatia','cuba','cyprus','czech republic','democratic republic of the congo','denmark','djibouti','dominica','dominican republic','east timor','ecuador','egypt','el salvador','equatorial guinea','eritrea','estonia','ethiopia','europa island','falkland islands','faroe islands','fiji','finland','france','french guiana','french polynesia','french southern and antarctic lands','gabon','gambia','gaza strip','georgia','germany','ghana','gibraltar','glorioso islands','greece','greenland','grenada','guadeloupe','guam','guatemala','guernsey','guinea','guinea-bissau','guyana','haiti','heard island and mcdonald islands','honduras','hong kong','howland island','hungary','iceland','india','indian ocean','indonesia','iran','iraq','ireland','isle of man','israel','italy','jamaica','jan mayen','japan','jarvis island','jersey','johnston atoll','jordan','juan de nova island','kazakhstan','kenya','kerguelen archipelago','kingman reef','kiribati','kosovo','kuwait','kyrgyzstan','laos','latvia','lebanon','lesotho','liberia','libya','liechtenstein','lithuania','luxembourg','macau','macedonia','madagascar','malawi','malaysia','maldives','mali','malta','marshall islands','martinique','mauritania','mauritius','mayotte','mediterranean sea','mexico','micronesia','midway islands','moldova','monaco','mongolia','montenegro','montserrat','morocco','mozambique','myanmar','namibia','nauru','navassa island','nepal','netherlands','netherlands antilles','new caledonia','new zealand','nicaragua','niger','nigeria','niue','norfolk island','north korea','north sea','northern mariana islands','norway','oman','pacific ocean','pakistan','palau','palmyra atoll','panama','papua new guinea','paracel islands','paraguay','peru','philippines','pitcairn islands','poland','portugal','puerto rico','qatar','republic of the congo','reunion','romania','ross sea','russia','rwanda','saint helena','saint kitts and nevis','saint lucia','saint pierre and miquelon','saint vincent and the grenadines','samoa','san marino','sao tome and principe','saudi arabia','senegal','serbia','seychelles','sierra leone','singapore','slovakia','slovenia','solomon islands','somalia','south africa','south georgia and the south sandwich islands','south korea','southern ocean','spain','spratly islands','sri lanka','sudan','suriname','svalbard','swaziland','sweden','switzerland','syria','taiwan','tajikistan','tanzania','tasman sea','thailand','togo','tokelau','tonga','trinidad and tobago','tromelin island','tunisia','turkey','turkmenistan','turks and caicos islands','tuvalu','uganda','ukraine','united arab emirates','united kingdom','uruguay','usa','uzbekistan','vanuatu','venezuela','viet nam','virgin islands','wake island','wallis and futuna','west bank','western sahara','yemen','zambia','zimbabwe'],
@@ -32,7 +32,7 @@
3232
*/
3333
$.formUtils.addValidator({
3434
name : 'federatestate',
35-
validate : function(str) {
35+
validatorFunction : function(str) {
3636
return $.inArray(str.toLowerCase(), this.states) > -1;
3737
},
3838
states : ['alabama','alaska','arkansas','california','colorado','connecticut','delaware','florida','georgia','hawaii','idaho','illinois','indiana','iowa','kansas','kentucky','louisiana','maine','marylan ','massachusetts','michigan','minnesota','mississippi','missouri','montana','nebraska','nevada','new hampshire','new jersey','new mexico','new york','north carolina','north dakota','ohio','oklahoma','oregon','pennsylvania','rhode island','south carolina','south dakota','tennessee','texas','utah','vermont','virginia','washington','west virginia','wisconsin','wyoming'],
@@ -43,7 +43,7 @@
4343

4444
$.formUtils.addValidator({
4545
name : 'longlat',
46-
validate : function(str) {
46+
validatorFunction : function(str) {
4747
var regexp = /^[+-]?\d+\.\d+, ?[+-]?\d+\.\d+$/;
4848
return regexp.test(str);
4949
},

0 commit comments

Comments
 (0)