PageSourceSearch

https://www.photocity.it/includes/master/js-css/checkInput.js?WMTOR2101258

js photocity.it collected 2026-10-02 08:14:23 UTC 11,109 bytes, 324 lines download raw bytes

1// CONTROLLI ESISTENTI PER CLASSE
2
3// tCheckEmail      : controlli email
4// tCheckText       : len min e max + no doppio spazio
5// tCheckName       : len min e max + no doppio spazio + no simboli
6// tCheckNumber     : len min e max + solo numeri
7// tCheckUsername   : len min e max + no spazi + no init 00,01,02,03 + no simboli
8// tCheckPassword   : len min e max + solo numeri e lettere
9
10// su tutti non sono ammessi i caratteri <>
11
12var checkExec = true;
13
14
15$(document).ready(function () {
16    caricaBlur();
17});
18
19
20function checkAllInput() {
21    checkExec = true;
22    $(':input').each(function () {
23        $(this).trigger("blur");
24    });
25
26    return checkExec;
27}
28
29
30function caricaBlur() {
31
32    $('.tCheckEmail').blur(
33      function () {
34          $(this).css("border", "");
35          checkTEmail($(this));
36      }
37    );
38
39    $('.tCheckText').blur(
40      function () {
41          $(this).css("border", "");
42          checkTText($(this));
43      }
44    );
45
46      $('.tCheckName').blur(
47      function () {
48          $(this).css("border", "");
49          checkTName($(this));
50      }
51    );
52
53      $('.tCheckNumber').blur(
54      function () {
55          $(this).css("border", "");
56          checkTNumber($(this));
57      }
58    );
59
60    $('.tCheckUsername').blur(
61      function () {
62          $(this).css("border", "");
63          checkTUsername($(this));
64      }
65    );
66
67      $('.tCheckPassword').blur(
68      function () {
69          $(this).css("border", "");
70          checkTPassword($(this));
71      }
72    );
73}
74
75// -----------------------------------------------------------------
76// -----------------------------------------------------------------
77
78function checkTEmail(obj) {
79    obj.val(obj.val().trim());
80
81    if ((obj.val().length < obj.attr("min")) || (obj.val().length > obj.attr("max"))) {
82        showMessage(obj, "Attenzione", "Il campo deve avere minimo " + obj.attr("min") + " e massimo " + obj.attr("max") + " caratteri");
83        return 0;
84    }
85
86
87    // Controllo Spazi
88    if (obj.val().indexOf(' ') >= 0) { showMessage(obj, "Attenzione", "Il campo non deve contenere Spazi"); return 0; }
89    // controllo @
90    var risposta = obj.val().split('@');
91    // Controllo mionomedominio.altro.it
92    if (risposta.length < 2) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Inserire simbolo @"); return 0; }
93
94    // Controllo mionome@[email protected]
95    if (risposta.length > 2) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Inserire un solo simbolo @"); return 0; }
96
97    // Controllo @dominio.it
98    if (obj.val().indexOf('@') <= 0) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Inserire il testo prima del simbolo @"); return 0; }
99
100    // Controllo ..
101    if (obj.val().split('..').length != 1) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Errore: non è possibile inserire doppio punto"); return 0; }
102
103    // Controllo .@
104    if (obj.val().split('.@').length != 1) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Errore: non è possibile inserire simbolo @ dopo il punto"); return 0; }
105
106
107    // controllo . dopo @
108
109    // Controllo @.
110    if (risposta[1].indexOf('.') <= 0) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Errore: non è possibile inserire punto dopo il simbolo @"); return 0; }
111
112    // Controllo [email protected]
113    //if (risposta[1].split('.').length != 2) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Errore:xxx non è possibile usare più punti dopo simbolo @"); return 0; }
114
115    // Controllo mionome@dominio.
116    if (risposta[1].indexOf('.') == (risposta[1].length - 1)) { showMessage(obj, "Attenzione", "Il campo deve essere del tipo [email protected]" + "<br />" + "Errore: non è possibile terminare con punto"); return 0; }
117
118    return 1;
119}
120
121// -----------------------------------------------------------------
122
123function checkTText(obj) {
124    while (obj.val().indexOf('  ') >= 0) { obj.val(obj.val().trim().replace('  ', ' ')); }
125
126    for (var i = 0; i < obj.val().length; i++) {
127        var xChar = obj.val().charCodeAt(i);
128        switch (true) {
129            case (xChar == 60):
130                showMessage(obj, "Attenzione", "Non è ammesso il carattere '<'");
131                break;
132            case (xChar == 62):
133                showMessage(obj, "Attenzione", "Non è ammesso il carattere '>'");
134                break;
135        }
136    }
137
138
139    if ((obj.val().length < obj.attr("min")) || (obj.val().length > obj.attr("max"))) {
140        showMessage(obj, "Attenzione", "Il campo deve avere minimo " + obj.attr("min") + " e massimo " + obj.attr("max") + " caratteri");
141        return 0;
142    }
143}
144
145// -----------------------------------------------------------------
146
147function checkTName(obj) {
148    while (obj.val().indexOf("''") >= 0) { obj.val(obj.val().trim().replace("''", "'")); }
149    while (obj.val().indexOf('  ') >= 0) { obj.val(obj.val().trim().replace('  ', ' ')); }
150
151    if ((obj.val().length < obj.attr("min")) || (obj.val().length > obj.attr("max"))) {
152        showMessage(obj, "Attenzione", "Il campo deve avere minimo " + obj.attr("min") + " e massimo " + obj.attr("max") + " caratteri");
153        return 0;
154    }
155
156    for (var i = 0; i < obj.val().length; i++) {
157
158        var xChar = obj.val().charCodeAt(i);
159        switch (true) {
160            case (xChar == 39):
161                // Apice
162                break;
163            case (xChar == 32):
164                // Spazio
165                break;
166            case (xChar >= 48 && xChar <= 57):
167                // Numeri
168                break;
169            case (xChar >= 65 && xChar <= 90):
170                // A..Z
171                break;
172            case (xChar >= 97 && xChar <= 122):
173                // a..z
174                break;
175            case (xChar >= 192 && xChar <= 214):
176                // Lettere accentate Maiuscole
177                break;
178            case (xChar >= 224 && xChar <= 246):
179                // Lettere accentate Maiuscole
180                break;
181            default:
182                showMessage(obj, "Attenzione", "Non è ammesso il carattere '" + obj.val()[i] + "'");
183                break;
184        }        
185    }
186
187
188}
189
190// -----------------------------------------------------------------
191
192function checkTNumber(obj) {
193
194    //obj.val(obj.val().trim().replace(/ /g, ''));
195    while (obj.val().indexOf('  ') >= 0) { obj.val(obj.val().trim().replace(' ', '')); }
196
197    if ((obj.val().length < obj.attr("min")) || (obj.val().length > obj.attr("max"))) {
198        var msg = "avere minimo " + obj.attr("min") + " e massimo " + obj.attr("max") + " numeri";
199        if (obj.attr("min") == obj.attr("max")) {
200          msg = "essere di " + obj.attr("min") + " numeri";
201        }
202        showMessage(obj, "Attenzione", "Il campo deve " + msg);
203        return 0;
204    }
205
206    for (var i = 0; i < obj.val().length; i++) {
207
208        var xChar = obj.val().charCodeAt(i);
209        switch (true) {
210            case (xChar >= 48 && xChar <= 57):
211                // Numeri
212                break;
213            default:
214                showMessage(obj, "Attenzione", "Non è ammesso il carattere '" + obj.val()[i] + "'");
215                break;
216        }
217    }
218
219}
220
221// -----------------------------------------------------------------
222
223function checkTUsername(obj) {
224    var strNoInit = "00,01,02,03"; 
225
226    if ((obj.val().length < obj.attr("min")) || (obj.val().length > obj.attr("max"))) {
227        showMessage(obj, "Attenzione", "Il campo deve avere minimo " + obj.attr("min") + " e massimo " + obj.attr("max") + " caratteri");
228        return 0;
229    }
230
231    if ( strNoInit.indexOf( obj.val().substring(0,2)) >= 0) {
232        showMessage(obj, "Attenzione", "Il campo non deve iniziare con '"+ strNoInit + "'");
233        return 0;
234    }
235
236    for (var i = 0; i < obj.val().length; i++) {
237        var xChar = obj.val().charCodeAt(i);
238        switch (true) {
239            case (xChar == 32):
240                showMessage(obj, "Attenzione", "Non è ammesso il carattere Spazio");
241                break;
242            case (xChar >= 48 && xChar <= 57):
243                // Numeri
244                break;
245            case (xChar >= 65 && xChar <= 90):
246                // A..Z
247                break;
248            case (xChar >= 97 && xChar <= 122):
249                // a..z
250                break;
251            case (xChar >= 192 && xChar <= 214):
252                // Lettere accentate Maiuscole
253                break;
254            case (xChar >= 224 && xChar <= 246):
255                // Lettere accentate Maiuscole
256                break;
257            default:
258                // Tutti gli altri
259                showMessage(obj, "Attenzione", "Non è ammesso il carattere '" + obj.val()[i] + "'");
260                break;
261        }
262    }
263
264
265}
266
267// -----------------------------------------------------------------
268
269function checkTPassword(obj) {
270
271    if ((obj.val().length < obj.attr("min")) || (obj.val().length > obj.attr("max"))) {
272        showMessage(obj, "Attenzione", "Il campo deve avere minimo " + obj.attr("min") + " e massimo " + obj.attr("max") + " caratteri");
273        return 0;
274    }
275
276    for (var i = 0; i < obj.val().length; i++) {
277        var xChar = obj.val().charCodeAt(i);
278        switch (true) {
279            case (xChar == 32):
280                showMessage(obj, "Attenzione", "Non è ammesso il carattere Spazio");
281                break;
282            case (xChar >= 48 && xChar <= 57):
283                // Numeri
284                break;
285            case (xChar >= 65 && xChar <= 90):
286                // A..Z
287                break;
288            case (xChar >= 97 && xChar <= 122):
289                // a..z
290                break;
291            case (xChar >= 192 && xChar <= 214):
292                // Lettere accentate Maiuscole
293                break;
294            case (xChar >= 224 && xChar <= 246):
295                // Lettere accentate Maiuscole
296                break;
297            default:
298                // Tutti gli altri
299                showMessage(obj, "Attenzione", "Non è ammesso il carattere '" + obj.val()[i] + "'");
300                break;
301        }
302    }
303
304
305
306}
307
308// -----------------------------------------------------------------
309// -----------------------------------------------------------------
310
311
312
313
314var n = 0;
315function showMessage(obj, titolo, msg) {
316    n++;
317    var nameClass = "infoInput" + n;
318    $("<p class='infoInput " + nameClass + "' >" + msg + "</p>").insertAfter(obj);
319    obj.css("border", "1px solid red");
320    setTimeout(function () { $("." + nameClass).remove(); }, 3000);
321
322    checkExec = false;
323}
324

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.