Skip to content

Commit cfcd71a

Browse files
committed
some fixes and extensions to the italian localization
1 parent a533cf7 commit cfcd71a

File tree

1 file changed

+135
-44
lines changed

1 file changed

+135
-44
lines changed
Lines changed: 135 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,72 @@
11
(function($){
2-
$.fn.validationEngineLanguage = function(){};
2+
$.fn.validationEngineLanguage = function(){
3+
};
34
$.validationEngineLanguage = {
45
newLang: function(){
56
$.validationEngineLanguage.allRules = {
67
"required": { // Add your regex rules here, you can take telephone as an example
78
"regex": "none",
89
"alertText": "* Campo richiesto",
910
"alertTextCheckboxMultiple": "* Per favore selezionare un'opzione",
10-
"alertTextCheckboxe": "* E' richiesta la selezione della casella"
11+
"alertTextCheckboxe": "* E' richiesta la selezione della casella",
12+
"alertTextDateRange": "* Sono richiesti entrambi gli intervalli temporali"
1113
},
12-
"requiredInFunction": {
14+
"requiredInFunction": {
1315
"func": function(field, rules, i, options){
1416
return (field.val() == "test") ? true : false;
1517
},
16-
"alertText": "* Field must equal test"
18+
"alertText": "* Il campo deve avere valore 'test'"
1719
},
18-
"length": {
20+
"dateRange": {
1921
"regex": "none",
20-
"alertText": "* Fra ",
21-
"alertText2": " e ",
22-
"alertText3": " caratteri permessi"
22+
"alertText": "* Intervallo ",
23+
"alertText2": "non valido"
2324
},
24-
"maxCheckbox": {
25+
"dateTimeRange": {
2526
"regex": "none",
26-
"alertText": "* Numero di caselle da selezionare in eccesso"
27+
"alertText": "* Intervallo ",
28+
"alertText2": "non valido"
2729
},
28-
"groupRequired": {
30+
"minSize": {
31+
"regex": "none",
32+
"alertText": "* E' richiesto un minimo di ",
33+
"alertText2": " caratteri"
34+
},
35+
"maxSize": {
36+
"regex": "none",
37+
"alertText": "* E' richiesto un massimo di ",
38+
"alertText2": " caratteri"
39+
},
40+
"groupRequired": {
41+
"regex": "none",
42+
"alertText": "* Uno dei seguenti campi deve essere selezionato",
43+
"alertTextCheckboxMultiple": "* Selezionare una opzione",
44+
"alertTextCheckboxe": "* Segno di spunta richiesto"
45+
},
46+
"min": {
47+
"regex": "none",
48+
"alertText": "* Il valore minimo accettato è "
49+
},
50+
"max": {
51+
"regex": "none",
52+
"alertText": "* Il valore massimo accettato è "
53+
},
54+
"past": {
55+
"regex": "none",
56+
"alertText": "* Data antecedente al "
57+
},
58+
"future": {
59+
"regex": "none",
60+
"alertText": "* Data successiva al "
61+
},
62+
"maxCheckbox": {
2963
"regex": "none",
30-
"alertText": "* You must fill one of the following fields"
64+
"alertText": "* Massimo ",
65+
"alertText2": " opzioni consentite"
3166
},
3267
"minCheckbox": {
3368
"regex": "none",
34-
"alertText": "* Per favore selezionare ",
69+
"alertText": "* Selezionare almeno ",
3570
"alertText2": " opzioni"
3671
},
3772
"equals": {
@@ -40,76 +75,132 @@
4075
},
4176
"creditCard": {
4277
"regex": "none",
43-
"alertText": "* Non valido numero di carta di credito"
78+
"alertText": "* Numero di carta di credito non valido"
4479
},
4580
"phone": {
4681
// credit: jquery.h5validate.js / orefalo
4782
"regex": /^([\+][0-9]{1,3}([ \.\-])?)?([\(][0-9]{1,6}[\)])?([0-9 \.\-]{1,32})(([A-Za-z \:]{1,11})?[0-9]{1,4}?)$/,
4883
"alertText": "* Numero di telefono non corretto"
4984
},
5085
"email": {
51-
// Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
52-
"regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
86+
// HTML5 compatible email regex ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html# e-mail-state-%28type=email%29 )
87+
"regex": /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
5388
"alertText": "* Indirizzo non corretto"
5489
},
90+
"fullname": {
91+
"regex":/^([a-zA-Z]+[\'\,\.\-]?[a-zA-Z ]*)+[ ]([a-zA-Z]+[\'\,\.\-]?[a-zA-Z ]+)+$/,
92+
"alertText":"* Nome e cognome richiesti"
93+
},
94+
"zip": {
95+
"regex":/^\d{5}$|^\d{5}-\d{4}$/,
96+
"alertText":"* Formato zip non valido"
97+
},
5598
"integer": {
5699
"regex": /^[\-\+]?\d+$/,
57-
"alertText": "* Numero intero non corretto"
100+
"alertText": "* Richiesto un numero intero"
58101
},
59102
"number": {
60-
// Number, including positive, negative, and floating decimal. Credit: bassistance
61-
"regex": /^[\-\+]?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)$/,
62-
"alertText": "* Numero decimale non corretto"
103+
// Number, including positive, negative, and floating decimal. credit: orefalo
104+
"regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/,
105+
"alertText": "* Richiesto un numero decimale"
63106
},
64107
"date": {
65-
"regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
66-
"alertText": "* Data non corretta, re-inserire secondo formato AAAA-MM-GG"
108+
// Check if date is valid by leap year
109+
"func": function (field) {
110+
var pattern = new RegExp(/^(\d{4})[\/\-\.](0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])$/);
111+
var match = pattern.exec(field.val());
112+
if (match == null)
113+
return false;
114+
115+
var year = match[1];
116+
var month = match[2]*1;
117+
var day = match[3]*1;
118+
var date = new Date(year, month - 1, day); // because months starts from 0.
119+
120+
return (date.getFullYear() == year && date.getMonth() == (month - 1) && date.getDate() == day);
121+
},
122+
"alertText": "* Data non corretta, è richeisto il formato AAAA-MM-GG"
67123
},
68-
69124
"ipv4": {
70-
"regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
125+
"regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
71126
"alertText": "* IP non corretto"
72127
},
73128
"url": {
74129
"regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
75130
"alertText": "* URL non corretta"
76131
},
77-
"onlyNumber": {
132+
"onlyNumberSp": {
78133
"regex": /^[0-9\ ]+$/,
79134
"alertText": "* Solo numeri"
80135
},
81-
"onlyLetter": {
136+
"onlyLetterSp": {
82137
"regex": /^[a-zA-Z\ \']+$/,
83138
"alertText": "* Solo lettere"
84139
},
85-
"onlyLetterAccentSp":{
140+
"onlyLetterAccentSp":{
86141
"regex": /^[a-z\u00C0-\u017F\ ]+$/i,
87-
"alertText": "* Solo lettere"
88-
},
89-
"validate2fields": {
90-
"nname": "validate2fields",
91-
"alertText": "* Occorre inserire nome e cognome"
142+
"alertText": "* Solo lettere (è possibile inserire lettere accentate)"
92143
},
93-
"noSpecialCharacters": {
144+
"onlyLetterNumber": {
94145
"regex": /^[0-9a-zA-Z]+$/,
95-
"alertText": "* Caratteri speciali non permessi"
146+
"alertText": "* Non è possibile inserire caratteri speciali"
96147
},
148+
// --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
97149
"ajaxUserCall": {
98-
"file": "ajaxValidateFieldName",
150+
"url": "ajaxValidateFieldUser",
151+
// you may want to pass extra data on the ajax call
99152
"extraData": "name=eric",
100-
"alertTextLoad": "* Caricamento, attendere per favore",
101-
"alertText": "* Questo user � gi� stato utilizzato"
153+
"alertText": "* Questo nome utente è già stato registrato",
154+
"alertTextLoad": "* Caricamento in corso, attendere prego"
155+
},
156+
"ajaxUserCallPhp": {
157+
"url": "phpajax/ajaxValidateFieldUser.php",
158+
// you may want to pass extra data on the ajax call
159+
"extraData": "name=eric",
160+
// if you provide an "alertTextOk", it will show as a green prompt when the field validates
161+
"alertTextOk": "* Questo nome utente è disponibile",
162+
"alertText": "* Questo nome utente è già stato registrato",
163+
"alertTextLoad": "* Caricamento in corso, attendere prego"
102164
},
103165
"ajaxNameCall": {
104-
"file": "ajaxValidateFieldName",
105-
"alertText": "* Questo nome � gi� stato utilizzato",
106-
"alertTextOk": "* Questo nome � disponibile",
107-
"alertTextLoad": "* Caricamento, attendere per favore"
166+
// remote json service location
167+
"url": "ajaxValidateFieldName",
168+
// error
169+
"alertText": "* Questo nome utente è già stato registrato",
170+
// if you provide an "alertTextOk", it will show as a green prompt when the field validates
171+
"alertTextOk": "* Questo nome utente è disponibile",
172+
// speaks by itself
173+
"alertTextLoad": "* Caricamento in corso, attendere prego"
174+
},
175+
"ajaxNameCallPhp": {
176+
// remote json service location
177+
"url": "phpajax/ajaxValidateFieldName.php",
178+
// error
179+
"alertText": "* Questo nome utente è già stato registrato",
180+
// speaks by itself
181+
"alertTextLoad": "* Caricamento in corso, attendere prego"
182+
},
183+
"validate2fields": {
184+
"alertText": "* Prego inserire 'HELLO'"
185+
},
186+
//tls warning:homegrown not fielded
187+
"dateFormat":{
188+
"regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
189+
"alertText": "* Data non valida"
190+
},
191+
//tls warning:homegrown not fielded
192+
"dateTimeFormat": {
193+
"regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
194+
"alertText": "* Data o formato non validi",
195+
"alertText2": "Formato richiesto: ",
196+
"alertText3": "mm/gg/aaaa oo:mm:ss AM|PM oppure ",
197+
"alertText4": "aaaa-mm-gg oo:mm:ss AM|PM"
108198
}
109-
110199
};
111-
200+
112201
}
113202
};
203+
114204
$.validationEngineLanguage.newLang();
115-
})(jQuery);
205+
206+
})(jQuery);

0 commit comments

Comments
 (0)