dqs-jquery-form-validator-rails 2.2.163 → 2.2.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +21 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +451 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/brazil.dev.js +115 -0
- data/app/assets/javascripts/brazil.js +9 -0
- data/app/assets/javascripts/date.dev.js +81 -0
- data/app/assets/javascripts/date.js +9 -0
- data/app/assets/javascripts/file.dev.js +413 -0
- data/app/assets/javascripts/file.js +9 -0
- data/app/assets/javascripts/html5.dev.js +168 -0
- data/app/assets/javascripts/html5.js +9 -0
- data/app/assets/javascripts/jquery.form-validator.min.js +9 -0
- data/app/assets/javascripts/jsconf.dev.js +55 -0
- data/app/assets/javascripts/jsconf.js +9 -0
- data/app/assets/javascripts/lang/cz.dev.js +65 -0
- data/app/assets/javascripts/lang/cz.js +9 -0
- data/app/assets/javascripts/lang/de.dev.js +65 -0
- data/app/assets/javascripts/lang/de.js +9 -0
- data/app/assets/javascripts/lang/es.dev.js +62 -0
- data/app/assets/javascripts/lang/es.js +9 -0
- data/app/assets/javascripts/lang/fr.dev.js +62 -0
- data/app/assets/javascripts/lang/fr.js +9 -0
- data/app/assets/javascripts/lang/it.dev.js +62 -0
- data/app/assets/javascripts/lang/it.js +9 -0
- data/app/assets/javascripts/lang/pl.dev.js +65 -0
- data/app/assets/javascripts/lang/pl.js +9 -0
- data/app/assets/javascripts/lang/pt.dev.js +65 -0
- data/app/assets/javascripts/lang/pt.js +9 -0
- data/app/assets/javascripts/lang/ro.dev.js +65 -0
- data/app/assets/javascripts/lang/ro.js +9 -0
- data/app/assets/javascripts/lang/ru.dev.js +66 -0
- data/app/assets/javascripts/lang/ru.js +9 -0
- data/app/assets/javascripts/lang/sv.dev.js +63 -0
- data/app/assets/javascripts/lang/sv.js +9 -0
- data/app/assets/javascripts/location.dev.js +78 -0
- data/app/assets/javascripts/location.js +9 -0
- data/app/assets/javascripts/sanitize.dev.js +154 -0
- data/app/assets/javascripts/sanitize.js +9 -0
- data/app/assets/javascripts/security.dev.js +523 -0
- data/app/assets/javascripts/security.js +9 -0
- data/app/assets/javascripts/src/core-validators.js +343 -0
- data/app/assets/javascripts/src/dialogs.js +123 -0
- data/app/assets/javascripts/src/jquery-plugins.js +452 -0
- data/app/assets/javascripts/src/module-loader.js +150 -0
- data/app/assets/javascripts/src/setup.js +168 -0
- data/app/assets/javascripts/src/utils.js +840 -0
- data/app/assets/javascripts/sweden.dev.js +213 -0
- data/app/assets/javascripts/sweden.js +9 -0
- data/app/assets/javascripts/theme-default.css +108 -0
- data/app/assets/javascripts/theme-default.min.css +1 -0
- data/app/assets/javascripts/toggleDisabled.dev.js +67 -0
- data/app/assets/javascripts/toggleDisabled.js +9 -0
- data/app/assets/javascripts/uk.dev.js +85 -0
- data/app/assets/javascripts/uk.js +9 -0
- data/dqs-jquery-form-validator.gemspec +27 -0
- data/lib/dqs-jquery-form-validator-rails.rb +1 -0
- data/lib/dqs/jquery/form/validator/rails.rb +13 -0
- data/lib/dqs/jquery/form/validator/rails/engine.rb +12 -0
- data/lib/dqs/jquery/form/validator/rails/version.rb +11 -0
- metadata +64 -2
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* JQUERY-FORM-VALIDATOR
|
3
|
+
*
|
4
|
+
* @version 2.2.163
|
5
|
+
* @website http://formvalidator.net/
|
6
|
+
* @author Victor Jonsson, http://victorjonsson.se
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
!function(a,b){"use strict";a(b).bind("validatorsLoaded",function(){a.formUtils.LANG={errorTitle:"Ошибка отправки формы!",requiredField:"Это обязательное поле",requiredFields:"Вы задали не все обязательные поля",badTime:"Вы задали некорректное время",badEmail:"Вы задали некорректный e-mail",badTelephone:"Вы задали некорректный номер телефона",badSecurityAnswer:"Вы задали некорректный ответ на секретный вопрос",badDate:"Вы задали некорректную дату",lengthBadStart:"Значение должно быть в диапазоне",lengthBadEnd:" символов",lengthTooLongStart:"Значение длинее, чем ",lengthTooShortStart:"Значение меньше, чем ",notConfirmed:"Введённые значения не могут быть подтверждены",badDomain:"Некорректное значение домена",badUrl:"Некорретный URL",badCustomVal:"Введённое значение неверно",andSpaces:" и пробелы ",badInt:"Значение - не число",badSecurityNumber:"Введённый защитный номер - неправильный",badUKVatAnswer:"Некорректный UK VAT номер",badStrength:"Пароль не достаточно надёжен",badNumberOfSelectedOptionsStart:"Вы должны выбрать как минимум ",badNumberOfSelectedOptionsEnd:" ответов",badAlphaNumeric:"Значение должно содержать только числа и буквы ",badAlphaNumericExtra:" и ",wrongFileSize:"Загружаемый файл слишком велик (максимальный размер %s)",wrongFileType:"Принимаются файлы следующих типов %s",groupCheckedRangeStart:"Выберите между ",groupCheckedTooFewStart:"Выберите как минимум ",groupCheckedTooManyStart:"Выберите максимум из ",groupCheckedEnd:" элемент(ов)",badCreditCard:"Номер кредитной карты некорректен",badCVV:"CVV номер некорректно",wrongFileDim:"Неверные размеры графического файла,",imageTooTall:"изображение не может быть уже чем",imageTooWide:"изображение не может быть шире чем",imageTooSmall:"изображение слишком мало",min:"минимум",max:"максимум",imageRatioNotAccepted:"Изображение с таким соотношением сторон не принимается",badBrazilTelephoneAnswer:"Введённый номер телефона неправильный",badBrazilCEPAnswer:"CEP неправильный",badBrazilCPFAnswer:"CPF неправильный"}})}(jQuery,window);
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Form Validator
|
3
|
+
* ------------------------------------------
|
4
|
+
*
|
5
|
+
* Swedish language package
|
6
|
+
*
|
7
|
+
* @website http://formvalidator.net/
|
8
|
+
* @license MIT
|
9
|
+
* @version 2.2.163
|
10
|
+
*/
|
11
|
+
(function($, window) {
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
$(window).bind('validatorsLoaded', function() {
|
16
|
+
|
17
|
+
$.formUtils.LANG = {
|
18
|
+
errorTitle: 'Formuläret kunde inte skickas!',
|
19
|
+
requiredField: 'Detta är ett obligtoriskt fält',
|
20
|
+
requiredFields: 'Du har inte besvarat alla frågor',
|
21
|
+
badTime: 'Du har inte angett en korrekt tidpunkt',
|
22
|
+
badEmail: 'Du har inte angett en korrekt e-postadress',
|
23
|
+
badTelephone: 'Du har inte angett ett korrekt telefonnummer',
|
24
|
+
badSecurityAnswer: 'Du har angett fel svar på säkerhetsfrågan',
|
25
|
+
badDate: 'Du har anget ett felaktigt datum',
|
26
|
+
lengthBadStart: 'Ditt svar måste innehålla mellan ',
|
27
|
+
lengthBadEnd: ' tecken',
|
28
|
+
lengthTooLongStart: 'Du har angett ett svar som är längre än ',
|
29
|
+
lengthTooShortStart: 'Du har angett ett svar som är kortare än ',
|
30
|
+
notConfirmed: 'Svaren kunde inte bekräfta varandra',
|
31
|
+
badDomain: 'Du har angett en inkorrekt domän',
|
32
|
+
badUrl: 'Du har inte angett en korrekt webbadress',
|
33
|
+
badCustomVal: 'Du har anget ett inkorrekt svar',
|
34
|
+
andSpaces: ' och mellanslag ',
|
35
|
+
badInt: 'Du har inte angett en siffra',
|
36
|
+
badSecurityNumber: 'Du har angett ett felaktigt personnummer',
|
37
|
+
badUKVatAnswer: 'Du har inte angett ett brittiskt moms-nummer',
|
38
|
+
badStrength: 'Du har angett ett lösenord som inte är nog säkert',
|
39
|
+
badNumberOfSelectedOptionsStart: 'Du måste åtminstone välja ',
|
40
|
+
badNumberOfSelectedOptionsEnd: ' svarsalternativ',
|
41
|
+
badAlphaNumeric: 'Du kan endast svara med alfanumersika tecken (a-z och siffror)',
|
42
|
+
badAlphaNumericExtra: ' och ',
|
43
|
+
wrongFileSize: 'Filen du försöker ladda upp är för stor (max %s)',
|
44
|
+
wrongFileType: 'Endast filer av typen %s är tillåtna',
|
45
|
+
groupCheckedRangeStart: 'Välj mellan ',
|
46
|
+
groupCheckedTooFewStart: 'Då måste göra minst ',
|
47
|
+
groupCheckedTooManyStart: 'Du får inte göra fler än ',
|
48
|
+
groupCheckedEnd: ' val',
|
49
|
+
badCreditCard: 'Du har angett ett felaktigt kreditkortsnummer',
|
50
|
+
badCVV: 'Du har angett ett felaktigt CVV-nummer',
|
51
|
+
wrongFileDim : 'Otillåten bildstorlek,',
|
52
|
+
imageTooTall : 'bilden får inte vara högre än',
|
53
|
+
imageTooWide : 'bilden får inte vara bredare än',
|
54
|
+
imageTooSmall : 'bilden är för liten',
|
55
|
+
genericBadInputValue : 'The input value can be accepted',
|
56
|
+
min : 'minst',
|
57
|
+
max : 'max',
|
58
|
+
imageRatioNotAccepted : 'Bildens dimensioner (förhållandet mellan höjd och längd) kan inte accepteras'
|
59
|
+
};
|
60
|
+
|
61
|
+
});
|
62
|
+
|
63
|
+
})(jQuery, window);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* JQUERY-FORM-VALIDATOR
|
3
|
+
*
|
4
|
+
* @version 2.2.163
|
5
|
+
* @website http://formvalidator.net/
|
6
|
+
* @author Victor Jonsson, http://victorjonsson.se
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
!function(a,b){"use strict";a(b).bind("validatorsLoaded",function(){a.formUtils.LANG={errorTitle:"Formuläret kunde inte skickas!",requiredField:"Detta är ett obligtoriskt fält",requiredFields:"Du har inte besvarat alla frågor",badTime:"Du har inte angett en korrekt tidpunkt",badEmail:"Du har inte angett en korrekt e-postadress",badTelephone:"Du har inte angett ett korrekt telefonnummer",badSecurityAnswer:"Du har angett fel svar på säkerhetsfrågan",badDate:"Du har anget ett felaktigt datum",lengthBadStart:"Ditt svar måste innehålla mellan ",lengthBadEnd:" tecken",lengthTooLongStart:"Du har angett ett svar som är längre än ",lengthTooShortStart:"Du har angett ett svar som är kortare än ",notConfirmed:"Svaren kunde inte bekräfta varandra",badDomain:"Du har angett en inkorrekt domän",badUrl:"Du har inte angett en korrekt webbadress",badCustomVal:"Du har anget ett inkorrekt svar",andSpaces:" och mellanslag ",badInt:"Du har inte angett en siffra",badSecurityNumber:"Du har angett ett felaktigt personnummer",badUKVatAnswer:"Du har inte angett ett brittiskt moms-nummer",badStrength:"Du har angett ett lösenord som inte är nog säkert",badNumberOfSelectedOptionsStart:"Du måste åtminstone välja ",badNumberOfSelectedOptionsEnd:" svarsalternativ",badAlphaNumeric:"Du kan endast svara med alfanumersika tecken (a-z och siffror)",badAlphaNumericExtra:" och ",wrongFileSize:"Filen du försöker ladda upp är för stor (max %s)",wrongFileType:"Endast filer av typen %s är tillåtna",groupCheckedRangeStart:"Välj mellan ",groupCheckedTooFewStart:"Då måste göra minst ",groupCheckedTooManyStart:"Du får inte göra fler än ",groupCheckedEnd:" val",badCreditCard:"Du har angett ett felaktigt kreditkortsnummer",badCVV:"Du har angett ett felaktigt CVV-nummer",wrongFileDim:"Otillåten bildstorlek,",imageTooTall:"bilden får inte vara högre än",imageTooWide:"bilden får inte vara bredare än",imageTooSmall:"bilden är för liten",genericBadInputValue:"The input value can be accepted",min:"minst",max:"max",imageRatioNotAccepted:"Bildens dimensioner (förhållandet mellan höjd och längd) kan inte accepteras"}})}(jQuery,window);
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Form Validator Module: Date
|
3
|
+
* ------------------------------------------
|
4
|
+
* Created by Victor Jonsson <http://www.victorjonsson.se>
|
5
|
+
*
|
6
|
+
* The following validators will be added by this module:
|
7
|
+
* - Country
|
8
|
+
* - US state
|
9
|
+
* - longitude and latitude
|
10
|
+
*
|
11
|
+
* @website http://formvalidator.net/#location-validators
|
12
|
+
* @license MIT
|
13
|
+
* @version 2.2.163
|
14
|
+
*/
|
15
|
+
(function($) {
|
16
|
+
|
17
|
+
/*
|
18
|
+
* Validate that country exists
|
19
|
+
*/
|
20
|
+
$.formUtils.addValidator({
|
21
|
+
name : 'country',
|
22
|
+
validatorFunction : function(str) {
|
23
|
+
return $.inArray(str.toLowerCase(), this.countries) > -1;
|
24
|
+
},
|
25
|
+
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'],
|
26
|
+
errorMessage : '',
|
27
|
+
errorMessageKey: 'badCustomVal'
|
28
|
+
});
|
29
|
+
|
30
|
+
/*
|
31
|
+
* Is this a valid federate state in the US
|
32
|
+
*/
|
33
|
+
$.formUtils.addValidator({
|
34
|
+
name : 'federatestate',
|
35
|
+
validatorFunction : function(str) {
|
36
|
+
return $.inArray(str.toLowerCase(), this.states) > -1;
|
37
|
+
},
|
38
|
+
states : ['alabama','alaska', 'arizona', 'arkansas','california','colorado','connecticut','delaware','florida','georgia','hawaii','idaho','illinois','indiana','iowa','kansas','kentucky','louisiana','maine','maryland', 'district of columbia', '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'],
|
39
|
+
errorMessage : '',
|
40
|
+
errorMessageKey: 'badCustomVal'
|
41
|
+
});
|
42
|
+
|
43
|
+
|
44
|
+
$.formUtils.addValidator({
|
45
|
+
name : 'longlat',
|
46
|
+
validatorFunction : function(str) {
|
47
|
+
var regexp = /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/;
|
48
|
+
return regexp.test(str);
|
49
|
+
},
|
50
|
+
errorMessage:'',
|
51
|
+
errorMessageKey:'badCustomVal'
|
52
|
+
});
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @private
|
56
|
+
* @param {Array} listItems
|
57
|
+
* @return {Array}
|
58
|
+
*/
|
59
|
+
var _makeSortedList = function(listItems) {
|
60
|
+
var newList = [];
|
61
|
+
$.each(listItems, function(i, v) {
|
62
|
+
newList.push(v.substr(0,1).toUpperCase() + v.substr(1, v.length));
|
63
|
+
});
|
64
|
+
newList.sort();
|
65
|
+
return newList;
|
66
|
+
};
|
67
|
+
|
68
|
+
$.fn.suggestCountry = function(settings) {
|
69
|
+
var country = _makeSortedList($.formUtils.validators.validate_country.countries);
|
70
|
+
return $.formUtils.suggest(this, country, settings);
|
71
|
+
};
|
72
|
+
|
73
|
+
$.fn.suggestState = function(settings) {
|
74
|
+
var states = _makeSortedList($.formUtils.validators.validate_federatestate.states);
|
75
|
+
return $.formUtils.suggest(this, states, settings);
|
76
|
+
};
|
77
|
+
|
78
|
+
})(jQuery);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* JQUERY-FORM-VALIDATOR
|
3
|
+
*
|
4
|
+
* @version 2.2.163
|
5
|
+
* @website http://formvalidator.net/
|
6
|
+
* @author Victor Jonsson, http://victorjonsson.se
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
!function(a){a.formUtils.addValidator({name:"country",validatorFunction:function(b){return a.inArray(b.toLowerCase(),this.countries)>-1},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"],errorMessage:"",errorMessageKey:"badCustomVal"}),a.formUtils.addValidator({name:"federatestate",validatorFunction:function(b){return a.inArray(b.toLowerCase(),this.states)>-1},states:["alabama","alaska","arizona","arkansas","california","colorado","connecticut","delaware","florida","georgia","hawaii","idaho","illinois","indiana","iowa","kansas","kentucky","louisiana","maine","maryland","district of columbia","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"],errorMessage:"",errorMessageKey:"badCustomVal"}),a.formUtils.addValidator({name:"longlat",validatorFunction:function(a){var b=/^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$/;return b.test(a)},errorMessage:"",errorMessageKey:"badCustomVal"});var b=function(b){var c=[];return a.each(b,function(a,b){c.push(b.substr(0,1).toUpperCase()+b.substr(1,b.length))}),c.sort(),c};a.fn.suggestCountry=function(c){var d=b(a.formUtils.validators.validate_country.countries);return a.formUtils.suggest(this,d,c)},a.fn.suggestState=function(c){var d=b(a.formUtils.validators.validate_federatestate.states);return a.formUtils.suggest(this,d,c)}}(jQuery);
|
@@ -0,0 +1,154 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Form Validator Module: sanitize
|
3
|
+
* ------------------------------------------
|
4
|
+
* Created by Victor Jonsson <http://www.victorjonsson.se>
|
5
|
+
*
|
6
|
+
* This module makes it possible to add sanitation functions to
|
7
|
+
* inputs. The functions is triggered on blur. Example:
|
8
|
+
*
|
9
|
+
* <input data-sanitize="uppercase trim" />
|
10
|
+
*
|
11
|
+
* Available functions are:
|
12
|
+
* - uppercase
|
13
|
+
* - lowercase
|
14
|
+
* - capitalize
|
15
|
+
* - trim
|
16
|
+
* - trimLeft
|
17
|
+
* - trimRight
|
18
|
+
* - numberFormat
|
19
|
+
* - insertLeft
|
20
|
+
* - insertRight
|
21
|
+
* - strip
|
22
|
+
* - escape (replace <, >, &, ' and " with HTML entities)
|
23
|
+
*
|
24
|
+
* @website http://formvalidator.net/
|
25
|
+
* @license MIT
|
26
|
+
* @version 2.2.163
|
27
|
+
*/
|
28
|
+
(function($, window) {
|
29
|
+
|
30
|
+
'use strict';
|
31
|
+
|
32
|
+
var inputsThatCantBeSanitized = '[type="button"], [type="submit"], [type="radio"], [type="checkbox"], [type="reset"], [type="search"]',
|
33
|
+
sanitizeCommands = {
|
34
|
+
upper : function(val) {
|
35
|
+
return val.toLocaleUpperCase();
|
36
|
+
},
|
37
|
+
lower : function(val) {
|
38
|
+
return val.toLocaleLowerCase();
|
39
|
+
},
|
40
|
+
trim : function(val) {
|
41
|
+
return $.trim(val);
|
42
|
+
},
|
43
|
+
trimLeft : function(val) {
|
44
|
+
return val.replace(/^\s+/,'');
|
45
|
+
},
|
46
|
+
trimRight : function(val) {
|
47
|
+
return val.replace(/\s+$/,'');
|
48
|
+
},
|
49
|
+
capitalize : function(val) {
|
50
|
+
var words = val.split(' ');
|
51
|
+
$.each(words, function(i, word) {
|
52
|
+
words[i] = word.substr(0,1).toUpperCase() + word.substr(1, word.length);
|
53
|
+
});
|
54
|
+
return words.join(' ');
|
55
|
+
},
|
56
|
+
insert : function(val, $input, pos) {
|
57
|
+
var extra = ($input.attr('data-sanitize-insert-'+pos) || '').replace(/\[SPACE\]/g, ' ');
|
58
|
+
if ( (pos === 'left' && val.indexOf(extra) === 0) || (pos === 'right' && val.substring(val.length - extra.length) === extra)) {
|
59
|
+
return val;
|
60
|
+
}
|
61
|
+
return (pos === 'left' ? extra:'') + val + (pos === 'right' ? extra : '');
|
62
|
+
},
|
63
|
+
insertRight : function(val, $input) {
|
64
|
+
return this.insert(val, $input, 'right');
|
65
|
+
},
|
66
|
+
insertLeft : function(val, $input) {
|
67
|
+
return this.insert(val, $input, 'left');
|
68
|
+
},
|
69
|
+
numberFormat : function(val, $input) {
|
70
|
+
if ( 'numeral' in window ) {
|
71
|
+
//If this has been previously formatted, it needs to be unformatted first before being reformatted.
|
72
|
+
//Else numeral will fail
|
73
|
+
val = numeral().unformat(val);
|
74
|
+
val = numeral(val).format( $input.attr('data-sanitize-number-format') );
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
throw new Error('Using sanitation function "numberFormat" requires that you include numeral.js ' +
|
78
|
+
'(http://numeraljs.com/)');
|
79
|
+
}
|
80
|
+
return val;
|
81
|
+
},
|
82
|
+
strip: function(val, $input) {
|
83
|
+
var toRemove = $input.attr('data-sanitize-strip') || '';
|
84
|
+
$.split(toRemove, function(char) {
|
85
|
+
val = val.replace(new RegExp('\\'+char, 'g'), '');
|
86
|
+
});
|
87
|
+
return val;
|
88
|
+
},
|
89
|
+
escape : function(val) {
|
90
|
+
var symbols = {
|
91
|
+
'<' : '__%AMP%__lt;',
|
92
|
+
'>' : '__%AMP%__gt;',
|
93
|
+
'&' : '__%AMP%__amp;',
|
94
|
+
'\'': '__%AMP%__#8217;',
|
95
|
+
'"' : '__%AMP%__quot;'
|
96
|
+
};
|
97
|
+
$.each(symbols, function(symbol, replacement) {
|
98
|
+
val = val.replace(new RegExp(symbol, 'g'), replacement);
|
99
|
+
});
|
100
|
+
return val.replace(new RegExp('__\%AMP\%__', 'g'), '&');
|
101
|
+
}
|
102
|
+
},
|
103
|
+
setupSanitation = function(evt, $forms, config) {
|
104
|
+
|
105
|
+
if ( !$forms ) {
|
106
|
+
$forms = $('form');
|
107
|
+
}
|
108
|
+
if ( !$forms.each ) {
|
109
|
+
$forms = $($forms);
|
110
|
+
}
|
111
|
+
|
112
|
+
var execSanitationCommands = function() {
|
113
|
+
var $input = $(this),
|
114
|
+
value = $input.val();
|
115
|
+
$.split($input.attr('data-sanitize'), function(command) {
|
116
|
+
if ( command in sanitizeCommands ) {
|
117
|
+
value = sanitizeCommands[command](value, $input, config);
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
throw new Error('Use of unknown sanitize command "'+command+'"');
|
121
|
+
}
|
122
|
+
});
|
123
|
+
$input
|
124
|
+
.val(value)
|
125
|
+
.trigger('keyup.validation'); // we need to re-validate in case it gets validated on blur
|
126
|
+
};
|
127
|
+
|
128
|
+
$forms.each(function() {
|
129
|
+
var $form = $(this);
|
130
|
+
if( config.sanitizeAll ) {
|
131
|
+
$form.find('input,textarea').not(inputsThatCantBeSanitized).each(function() {
|
132
|
+
var $input = $(this),
|
133
|
+
sanitation = $input.attr('data-sanitize') || '';
|
134
|
+
$input.attr('data-sanitize', config.sanitizeAll +' '+ sanitation);
|
135
|
+
});
|
136
|
+
}
|
137
|
+
|
138
|
+
$form.find('[data-sanitize]')
|
139
|
+
.unbind('blur.sanitation', execSanitationCommands)
|
140
|
+
.bind('blur.sanitation', execSanitationCommands);
|
141
|
+
|
142
|
+
$(function() {
|
143
|
+
$form.trigger('blur.sanitation');
|
144
|
+
});
|
145
|
+
|
146
|
+
});
|
147
|
+
};
|
148
|
+
|
149
|
+
$(window).on('validatorsLoaded formValidationSetup', setupSanitation);
|
150
|
+
|
151
|
+
// Only for unit testing
|
152
|
+
$.formUtils.setupSanitation = setupSanitation;
|
153
|
+
|
154
|
+
})(jQuery, window);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* JQUERY-FORM-VALIDATOR
|
3
|
+
*
|
4
|
+
* @version 2.2.163
|
5
|
+
* @website http://formvalidator.net/
|
6
|
+
* @author Victor Jonsson, http://victorjonsson.se
|
7
|
+
* @license MIT
|
8
|
+
*/
|
9
|
+
!function(a,b){"use strict";var c='[type="button"], [type="submit"], [type="radio"], [type="checkbox"], [type="reset"], [type="search"]',d={upper:function(a){return a.toLocaleUpperCase()},lower:function(a){return a.toLocaleLowerCase()},trim:function(b){return a.trim(b)},trimLeft:function(a){return a.replace(/^\s+/,"")},trimRight:function(a){return a.replace(/\s+$/,"")},capitalize:function(b){var c=b.split(" ");return a.each(c,function(a,b){c[a]=b.substr(0,1).toUpperCase()+b.substr(1,b.length)}),c.join(" ")},insert:function(a,b,c){var d=(b.attr("data-sanitize-insert-"+c)||"").replace(/\[SPACE\]/g," ");return"left"===c&&0===a.indexOf(d)||"right"===c&&a.substring(a.length-d.length)===d?a:("left"===c?d:"")+a+("right"===c?d:"")},insertRight:function(a,b){return this.insert(a,b,"right")},insertLeft:function(a,b){return this.insert(a,b,"left")},numberFormat:function(a,c){if(!("numeral"in b))throw new Error('Using sanitation function "numberFormat" requires that you include numeral.js (http://numeraljs.com/)');return a=numeral().unformat(a),a=numeral(a).format(c.attr("data-sanitize-number-format"))},strip:function(b,c){var d=c.attr("data-sanitize-strip")||"";return a.split(d,function(a){b=b.replace(new RegExp("\\"+a,"g"),"")}),b},escape:function(b){var c={"<":"__%AMP%__lt;",">":"__%AMP%__gt;","&":"__%AMP%__amp;","'":"__%AMP%__#8217;",'"':"__%AMP%__quot;"};return a.each(c,function(a,c){b=b.replace(new RegExp(a,"g"),c)}),b.replace(new RegExp("__%AMP%__","g"),"&")}},e=function(b,e,f){e||(e=a("form")),e.each||(e=a(e));var g=function(){var b=a(this),c=b.val();a.split(b.attr("data-sanitize"),function(a){if(!(a in d))throw new Error('Use of unknown sanitize command "'+a+'"');c=d[a](c,b,f)}),b.val(c).trigger("keyup.validation")};e.each(function(){var b=a(this);f.sanitizeAll&&b.find("input,textarea").not(c).each(function(){var b=a(this),c=b.attr("data-sanitize")||"";b.attr("data-sanitize",f.sanitizeAll+" "+c)}),b.find("[data-sanitize]").unbind("blur.sanitation",g).bind("blur.sanitation",g),a(function(){b.trigger("blur.sanitation")})})};a(b).on("validatorsLoaded formValidationSetup",e),a.formUtils.setupSanitation=e}(jQuery,window);
|
@@ -0,0 +1,523 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Form Validator Module: Security
|
3
|
+
* ------------------------------------------
|
4
|
+
* Created by Victor Jonsson <http://victorjonsson.se>
|
5
|
+
*
|
6
|
+
* This module adds validators typically used in registration forms.
|
7
|
+
* This module adds the following validators:
|
8
|
+
* - spamcheck
|
9
|
+
* - confirmation
|
10
|
+
* - strength
|
11
|
+
* - backend
|
12
|
+
* - credit card
|
13
|
+
* - cvv
|
14
|
+
*
|
15
|
+
* @website http://formvalidator.net/#security-validators
|
16
|
+
* @license MIT
|
17
|
+
* @version 2.2.163
|
18
|
+
*/
|
19
|
+
(function($, window) {
|
20
|
+
|
21
|
+
'use strict';
|
22
|
+
|
23
|
+
/*
|
24
|
+
* Simple spam check
|
25
|
+
*/
|
26
|
+
$.formUtils.addValidator({
|
27
|
+
name : 'spamcheck',
|
28
|
+
validatorFunction : function(val, $el) {
|
29
|
+
var attr = $el.valAttr('captcha');
|
30
|
+
return attr === val;
|
31
|
+
},
|
32
|
+
errorMessage : '',
|
33
|
+
errorMessageKey: 'badSecurityAnswer'
|
34
|
+
});
|
35
|
+
|
36
|
+
|
37
|
+
/*
|
38
|
+
* Validate confirmation
|
39
|
+
*/
|
40
|
+
$.formUtils.addValidator({
|
41
|
+
name : 'confirmation',
|
42
|
+
validatorFunction : function(value, $el, config, language, $form) {
|
43
|
+
var conf = '',
|
44
|
+
confInputName = $el.valAttr('confirm') || ($el.attr('name') + '_confirmation'),
|
45
|
+
$confInput = $form.find('[name="' +confInputName+ '"]').eq(0);
|
46
|
+
|
47
|
+
if ( $confInput ) {
|
48
|
+
conf = $confInput.val();
|
49
|
+
if( config.validateOnBlur && !$confInput[0].hasValidationCallback ) {
|
50
|
+
$confInput[0].hasValidationCallback = true;
|
51
|
+
var keyUpCallback = function() {
|
52
|
+
$el.validate();
|
53
|
+
};
|
54
|
+
$confInput.on('keyup', keyUpCallback);
|
55
|
+
$form.one('formValidationSetup', function() {
|
56
|
+
$confInput[0].hasValidationCallback = false;
|
57
|
+
$confInput.off('keyup', keyUpCallback);
|
58
|
+
});
|
59
|
+
}
|
60
|
+
} else {
|
61
|
+
alert('Could not find an input with name "'+confInputName+'"');
|
62
|
+
}
|
63
|
+
|
64
|
+
return value === conf;
|
65
|
+
},
|
66
|
+
errorMessage : '',
|
67
|
+
errorMessageKey: 'notConfirmed'
|
68
|
+
});
|
69
|
+
|
70
|
+
var creditCards = {
|
71
|
+
'amex' : [15,15],
|
72
|
+
'diners_club' : [14,14],
|
73
|
+
'cjb' : [16,16],
|
74
|
+
'laser' : [16,19],
|
75
|
+
'visa' : [16,16],
|
76
|
+
'mastercard' : [16,16],
|
77
|
+
'maestro' : [12,19],
|
78
|
+
'discover' : [16,16]
|
79
|
+
},
|
80
|
+
checkOnlyAmex = false,
|
81
|
+
allowsAmex = false;
|
82
|
+
|
83
|
+
/*
|
84
|
+
* Credit card
|
85
|
+
*/
|
86
|
+
$.formUtils.addValidator({
|
87
|
+
name : 'creditcard',
|
88
|
+
validatorFunction : function(value, $el) {
|
89
|
+
var allowing = $.split( $el.valAttr('allowing') || '' );
|
90
|
+
|
91
|
+
// Setup for cvv validation
|
92
|
+
allowsAmex = $.inArray('amex', allowing) > -1;
|
93
|
+
checkOnlyAmex = allowsAmex && allowing.length === 1;
|
94
|
+
|
95
|
+
// Correct length
|
96
|
+
if( allowing.length > 0 ) {
|
97
|
+
var hasValidLength = false;
|
98
|
+
$.each(allowing, function(i, cardName) {
|
99
|
+
if( cardName in creditCards) {
|
100
|
+
if( value.length >= creditCards[cardName][0] && value.length <= creditCards[cardName][1]) {
|
101
|
+
hasValidLength = true;
|
102
|
+
return false;
|
103
|
+
}
|
104
|
+
} else if( window.console ) {
|
105
|
+
console.warn('Use of unknown credit card "'+cardName+'"');
|
106
|
+
}
|
107
|
+
});
|
108
|
+
|
109
|
+
if ( !hasValidLength ) {
|
110
|
+
return false;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
// only numbers
|
115
|
+
if ( value.replace(new RegExp('[0-9]', 'g'), '') !== '' ) {
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
|
119
|
+
// http://en.wikipedia.org/wiki/Luhn_algorithm
|
120
|
+
// http://www.brainjar.com/js/validation/default2.asp
|
121
|
+
var checkSum = 0;
|
122
|
+
$.each(value.split('').reverse(), function(i, digit) {
|
123
|
+
digit = parseInt(digit, 10);
|
124
|
+
if( i%2 === 0 ) {
|
125
|
+
checkSum += digit;
|
126
|
+
} else {
|
127
|
+
digit *= 2;
|
128
|
+
if (digit < 10) {
|
129
|
+
checkSum += digit;
|
130
|
+
} else {
|
131
|
+
checkSum += digit - 9;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
});
|
135
|
+
return checkSum % 10 === 0;
|
136
|
+
},
|
137
|
+
errorMessage : '',
|
138
|
+
errorMessageKey: 'badCreditCard'
|
139
|
+
});
|
140
|
+
|
141
|
+
|
142
|
+
/*
|
143
|
+
* Credit card number
|
144
|
+
*/
|
145
|
+
$.formUtils.addValidator({
|
146
|
+
name : 'cvv',
|
147
|
+
validatorFunction : function(val) {
|
148
|
+
if( val.replace(/[0-9]/g, '') === '' ) {
|
149
|
+
val = val + '';
|
150
|
+
if( checkOnlyAmex ) {
|
151
|
+
return val.length === 4;
|
152
|
+
} else if( allowsAmex ) {
|
153
|
+
return val.length === 3 || val.length === 4;
|
154
|
+
} else {
|
155
|
+
return val.length === 3;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
return false;
|
159
|
+
},
|
160
|
+
errorMessage : '',
|
161
|
+
errorMessageKey: 'badCVV'
|
162
|
+
});
|
163
|
+
|
164
|
+
/*
|
165
|
+
* Validate password strength
|
166
|
+
*/
|
167
|
+
$.formUtils.addValidator({
|
168
|
+
name : 'strength',
|
169
|
+
validatorFunction : function(val, $el) {
|
170
|
+
var requiredStrength = $el.valAttr('strength') || 2;
|
171
|
+
if (requiredStrength && requiredStrength > 3) {
|
172
|
+
requiredStrength = 3;
|
173
|
+
}
|
174
|
+
|
175
|
+
return $.formUtils.validators.validate_strength.calculatePasswordStrength(val) >= requiredStrength;
|
176
|
+
},
|
177
|
+
errorMessage : '',
|
178
|
+
errorMessageKey: 'badStrength',
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Code more or less borrowed from jQuery plugin "Password Strength Meter"
|
182
|
+
* written by Darren Mason (djmason9@gmail.com), myPocket technologies (www.mypocket-technologies.com)
|
183
|
+
* @param {String} password
|
184
|
+
* @return {Number}
|
185
|
+
*/
|
186
|
+
calculatePasswordStrength : function(password) {
|
187
|
+
|
188
|
+
if (password.length < 4) {
|
189
|
+
return 0;
|
190
|
+
}
|
191
|
+
|
192
|
+
var score = 0;
|
193
|
+
|
194
|
+
var checkRepetition = function (pLen, str) {
|
195
|
+
var res = '';
|
196
|
+
for (var i = 0; i < str.length; i++) {
|
197
|
+
var repeated = true;
|
198
|
+
|
199
|
+
for (var j = 0; j < pLen && (j + i + pLen) < str.length; j++) {
|
200
|
+
repeated = repeated && (str.charAt(j + i) === str.charAt(j + i + pLen));
|
201
|
+
}
|
202
|
+
if (j < pLen) {
|
203
|
+
repeated = false;
|
204
|
+
}
|
205
|
+
if (repeated) {
|
206
|
+
i += pLen - 1;
|
207
|
+
repeated = false;
|
208
|
+
}
|
209
|
+
else {
|
210
|
+
res += str.charAt(i);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
return res;
|
214
|
+
};
|
215
|
+
|
216
|
+
//password length
|
217
|
+
score += password.length * 4;
|
218
|
+
score += ( checkRepetition(1, password).length - password.length ) * 1;
|
219
|
+
score += ( checkRepetition(2, password).length - password.length ) * 1;
|
220
|
+
score += ( checkRepetition(3, password).length - password.length ) * 1;
|
221
|
+
score += ( checkRepetition(4, password).length - password.length ) * 1;
|
222
|
+
|
223
|
+
//password has 3 numbers
|
224
|
+
if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) {
|
225
|
+
score += 5;
|
226
|
+
}
|
227
|
+
|
228
|
+
//password has 2 symbols
|
229
|
+
if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) {
|
230
|
+
score += 5;
|
231
|
+
}
|
232
|
+
|
233
|
+
//password has Upper and Lower chars
|
234
|
+
if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) {
|
235
|
+
score += 10;
|
236
|
+
}
|
237
|
+
|
238
|
+
//password has number and chars
|
239
|
+
if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) {
|
240
|
+
score += 15;
|
241
|
+
}
|
242
|
+
//
|
243
|
+
//password has number and symbol
|
244
|
+
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) {
|
245
|
+
score += 15;
|
246
|
+
}
|
247
|
+
|
248
|
+
//password has char and symbol
|
249
|
+
if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) {
|
250
|
+
score += 15;
|
251
|
+
}
|
252
|
+
|
253
|
+
//password is just a numbers or chars
|
254
|
+
if (password.match(/^\w+$/) || password.match(/^\d+$/)) {
|
255
|
+
score -= 10;
|
256
|
+
}
|
257
|
+
|
258
|
+
//verifying 0 < score < 100
|
259
|
+
if (score < 0) {
|
260
|
+
score = 0;
|
261
|
+
}
|
262
|
+
if (score > 100) {
|
263
|
+
score = 100;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (score < 20) {
|
267
|
+
return 0;
|
268
|
+
}
|
269
|
+
else if (score < 40) {
|
270
|
+
return 1;
|
271
|
+
}
|
272
|
+
else if(score <= 60) {
|
273
|
+
return 2;
|
274
|
+
}
|
275
|
+
else {
|
276
|
+
return 3;
|
277
|
+
}
|
278
|
+
},
|
279
|
+
|
280
|
+
strengthDisplay : function($el, options) {
|
281
|
+
var config = {
|
282
|
+
fontSize: '12pt',
|
283
|
+
padding: '4px',
|
284
|
+
bad : 'Very bad',
|
285
|
+
weak : 'Weak',
|
286
|
+
good : 'Good',
|
287
|
+
strong : 'Strong'
|
288
|
+
};
|
289
|
+
|
290
|
+
if (options) {
|
291
|
+
$.extend(config, options);
|
292
|
+
}
|
293
|
+
|
294
|
+
$el.bind('keyup', function() {
|
295
|
+
var val = $(this).val(),
|
296
|
+
$parent = typeof config.parent === 'undefined' ? $(this).parent() : $(config.parent),
|
297
|
+
$displayContainer = $parent.find('.strength-meter'),
|
298
|
+
strength = $.formUtils.validators.validate_strength.calculatePasswordStrength(val),
|
299
|
+
css = {
|
300
|
+
background: 'pink',
|
301
|
+
color : '#FF0000',
|
302
|
+
fontWeight : 'bold',
|
303
|
+
border : 'red solid 1px',
|
304
|
+
borderWidth : '0px 0px 4px',
|
305
|
+
display : 'inline-block',
|
306
|
+
fontSize : config.fontSize,
|
307
|
+
padding : config.padding
|
308
|
+
},
|
309
|
+
text = config.bad;
|
310
|
+
|
311
|
+
if($displayContainer.length === 0) {
|
312
|
+
$displayContainer = $('<span></span>');
|
313
|
+
$displayContainer
|
314
|
+
.addClass('strength-meter')
|
315
|
+
.appendTo($parent);
|
316
|
+
}
|
317
|
+
|
318
|
+
if( !val ) {
|
319
|
+
$displayContainer.hide();
|
320
|
+
} else {
|
321
|
+
$displayContainer.show();
|
322
|
+
}
|
323
|
+
|
324
|
+
if(strength === 1) {
|
325
|
+
text = config.weak;
|
326
|
+
}
|
327
|
+
else if(strength === 2) {
|
328
|
+
css.background = 'lightyellow';
|
329
|
+
css.borderColor = 'yellow';
|
330
|
+
css.color = 'goldenrod';
|
331
|
+
text = config.good;
|
332
|
+
}
|
333
|
+
else if(strength >= 3) {
|
334
|
+
css.background = 'lightgreen';
|
335
|
+
css.borderColor = 'darkgreen';
|
336
|
+
css.color = 'darkgreen';
|
337
|
+
text = config.strong;
|
338
|
+
}
|
339
|
+
|
340
|
+
$displayContainer
|
341
|
+
.css(css)
|
342
|
+
.text(text);
|
343
|
+
});
|
344
|
+
}
|
345
|
+
});
|
346
|
+
|
347
|
+
var requestServer = function(serverURL, $element, val, conf, callback) {
|
348
|
+
var reqParams = $element.valAttr('req-params') || $element.data('validation-req-params') || {},
|
349
|
+
handleResponse = function(response, callback) {
|
350
|
+
if(response.valid) {
|
351
|
+
$element.valAttr('backend-valid', 'true');
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
$element.valAttr('backend-invalid', 'true');
|
355
|
+
if (response.message) {
|
356
|
+
$element.attr(conf.validationErrorMsgAttribute, response.message);
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
if( !$element.valAttr('has-keyup-event') ) {
|
361
|
+
$element
|
362
|
+
.valAttr('has-keyup-event', '1')
|
363
|
+
.bind('keyup change', function(evt) {
|
364
|
+
if( evt.keyCode !== 9 && evt.keyCode !== 16 ) {
|
365
|
+
$(this)
|
366
|
+
.valAttr('backend-valid', false)
|
367
|
+
.valAttr('backend-invalid', false);
|
368
|
+
}
|
369
|
+
});
|
370
|
+
}
|
371
|
+
|
372
|
+
callback();
|
373
|
+
};
|
374
|
+
|
375
|
+
if ( !reqParams ) {
|
376
|
+
reqParams = {};
|
377
|
+
}
|
378
|
+
if ( typeof reqParams === 'string' ) {
|
379
|
+
reqParams = $.parseJSON(reqParams);
|
380
|
+
}
|
381
|
+
reqParams[$element.valAttr('param-name') || $element.attr('name')] = val;
|
382
|
+
|
383
|
+
$.ajax({
|
384
|
+
url : serverURL,
|
385
|
+
type : 'POST',
|
386
|
+
cache : false,
|
387
|
+
data : reqParams,
|
388
|
+
dataType : 'json',
|
389
|
+
error : function(error) {
|
390
|
+
handleResponse({valid: false, message:'Connection failed with status: ' + error.statusText}, callback);
|
391
|
+
return false;
|
392
|
+
},
|
393
|
+
success : function(response) {
|
394
|
+
handleResponse(response, callback);
|
395
|
+
}
|
396
|
+
});
|
397
|
+
},
|
398
|
+
disableFormSubmit = function() {
|
399
|
+
return false;
|
400
|
+
};
|
401
|
+
|
402
|
+
/*
|
403
|
+
* Server validation
|
404
|
+
* Flow (form submission):
|
405
|
+
* 1) Check if the value already has been validated on the server. If so, display the validation
|
406
|
+
* result and continue the validation process, otherwise continue to step 2
|
407
|
+
* 2) Return false as if the value is invalid and set $.formUtils.haltValidation to true
|
408
|
+
* 3) Disable form submission on the form being validated
|
409
|
+
* 4) Request the server with value and input name and add class 'validating-server-side' to the form
|
410
|
+
* 5) When the server responds an attribute will be added to the element
|
411
|
+
* telling the validator that the input has a valid/invalid value and enable form submission
|
412
|
+
* 6) Run form submission again (back to step 1)
|
413
|
+
*/
|
414
|
+
$.formUtils.addValidator({
|
415
|
+
name : 'server',
|
416
|
+
validatorFunction : function(val, $el, conf, lang, $form) {
|
417
|
+
|
418
|
+
var backendValid = $el.valAttr('backend-valid'),
|
419
|
+
backendInvalid = $el.valAttr('backend-invalid'),
|
420
|
+
serverURL = document.location.href;
|
421
|
+
|
422
|
+
if($el.valAttr('url')) {
|
423
|
+
serverURL = $el.valAttr('url');
|
424
|
+
} else if('serverURL' in conf) {
|
425
|
+
serverURL = conf.backendUrl;
|
426
|
+
}
|
427
|
+
|
428
|
+
if (backendValid) {
|
429
|
+
return true;
|
430
|
+
}
|
431
|
+
else if (backendInvalid) {
|
432
|
+
return false;
|
433
|
+
}
|
434
|
+
else if($.formUtils.eventType === 'keyup' && !$.formUtils.isValidatingEntireForm) {
|
435
|
+
return null;
|
436
|
+
}
|
437
|
+
|
438
|
+
if ($.formUtils.isValidatingEntireForm) {
|
439
|
+
$form
|
440
|
+
.bind('submit', disableFormSubmit)
|
441
|
+
.addClass('validating-server-side')
|
442
|
+
.addClass('on-blur');
|
443
|
+
|
444
|
+
$el.addClass('validating-server-side');
|
445
|
+
$.formUtils.haltValidation = true;
|
446
|
+
|
447
|
+
requestServer(serverURL, $el, val, conf, function() {
|
448
|
+
|
449
|
+
$form
|
450
|
+
.removeClass('validating-server-side')
|
451
|
+
.removeClass('on-blur')
|
452
|
+
.get(0).onsubmit = function() {};
|
453
|
+
|
454
|
+
$form.unbind('submit', disableFormSubmit);
|
455
|
+
$el.removeClass('validating-server-side');
|
456
|
+
|
457
|
+
$el.valAttr('value-length', val.length);
|
458
|
+
|
459
|
+
// fire submission again!
|
460
|
+
$.formUtils.haltValidation = false;
|
461
|
+
$form.trigger('submit');
|
462
|
+
});
|
463
|
+
|
464
|
+
return null;
|
465
|
+
|
466
|
+
} else {
|
467
|
+
// validation on blur
|
468
|
+
$form.addClass('validating-server-side');
|
469
|
+
$el.addClass('validating-server-side');
|
470
|
+
requestServer(serverURL, $el, val, conf, function() {
|
471
|
+
$form.removeClass('validating-server-side');
|
472
|
+
$el.removeClass('validating-server-side');
|
473
|
+
$el.trigger('blur');
|
474
|
+
});
|
475
|
+
return null;
|
476
|
+
}
|
477
|
+
},
|
478
|
+
errorMessage : '',
|
479
|
+
errorMessageKey: 'badBackend',
|
480
|
+
validateOnKeyUp : false
|
481
|
+
});
|
482
|
+
|
483
|
+
|
484
|
+
/*
|
485
|
+
* Check for only letters and numbers
|
486
|
+
*
|
487
|
+
* http://www.slovo.info/testuni.htm
|
488
|
+
*/
|
489
|
+
$.formUtils.addValidator({
|
490
|
+
name : 'letternumeric',
|
491
|
+
validatorFunction : function(val, $el, config, language) {
|
492
|
+
var patternStart = '^([a-zA-Z0-9\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC',
|
493
|
+
patternEnd = ']+)$',
|
494
|
+
additionalChars = $el.valAttr('allowing'),
|
495
|
+
pattern = '';
|
496
|
+
|
497
|
+
if (additionalChars) {
|
498
|
+
pattern = patternStart + additionalChars + patternEnd;
|
499
|
+
var extra = additionalChars.replace(/\\/g, '');
|
500
|
+
if (extra.indexOf(' ') > -1) {
|
501
|
+
extra = extra.replace(' ', '');
|
502
|
+
extra += language.andSpaces || $.formUtils.LANG.andSpaces;
|
503
|
+
}
|
504
|
+
this.errorMessage = language.badAlphaNumeric + language.badAlphaNumericExtra + extra;
|
505
|
+
} else {
|
506
|
+
pattern = patternStart + patternEnd;
|
507
|
+
this.errorMessage = language.badAlphaNumeric;
|
508
|
+
}
|
509
|
+
|
510
|
+
return new RegExp(pattern).test(val);
|
511
|
+
},
|
512
|
+
errorMessage : '',
|
513
|
+
errorMessageKey: 'requiredFields'
|
514
|
+
});
|
515
|
+
|
516
|
+
|
517
|
+
|
518
|
+
$.fn.displayPasswordStrength = function(conf) {
|
519
|
+
new $.formUtils.validators.validate_strength.strengthDisplay(this, conf);
|
520
|
+
return this;
|
521
|
+
};
|
522
|
+
|
523
|
+
})(jQuery, window);
|