PageSourceSearch

https://www.ambulatorioveterinariosismondi.eu/version_2/js/form_verifica.js

js ambulatorioveterinariosismondi.eu collected 2026-10-04 01:56:35 UTC 8,980 bytes, 408 lines download raw bytes

1$(function(){
2	
3	var numero_minimo = 1;
4	var numero_minimo_range = 1;
5	var last_error = '';	
6	
7	//alert('ok');
8	
9	$("[select-campo]").change(function(){
10		
11		//alert('ok');
12		
13		$("[elenco-campi]").each(function()
14		{
15			if($(this).attr("campo_condizionale") != '')	
16				$(this).hide(); 
17						
18		});
19		
20		$("[select-campo]").each(function()
21		{
22			valore_condizionale = $('option:selected', $(this)).attr('valore_condizionale');
23			//alert(valore_condizionale);
24			if(valore_condizionale != "" && $(this).is(':visible')){
25				
26				$("."+valore_condizionale).show(); 
27				
28			}		
29		});
30		
31	});
32	
33	
34	$("[form-campo]").keyup(function(){
35		//alert('ok');
36		let _this = $(this);
37		let val = _this.val();
38		let _attr = _this.attr('form-campo').split('|');
39		let _id_box = _attr[0];
40		let _campo = _attr[1];
41		let _tipo = _attr[2];
42		let _obbligatorio = _attr[3];
43		let _campo_logico = _attr[4];
44		let _peso = _attr[5];
45		
46		switch(_tipo) {
47			
48			case 'text':
49			case 'textarea':
50				
51				if(_campo_logico != ''){
52					
53					$.ajax({
54
55						type: "POST",
56						url: '/version_2/jfiles/form_verifica.php',
57						dataType: "json",
58						data: {
59							"type": _campo_logico,
60							"namespace": _id_box,
61							"valore": val.trim(),
62						},
63						success: function(data) {
64							//alert(data.error);
65							if(data.error != ''){
66								_this.attr('form-error',data.error);
67							}else{
68								_this.attr('form-error','');
69							}
70
71						},
72						error: function(data) { console.error(data); }
73
74					});
75					
76					
77				}
78				if(_peso > 0){
79					
80					peso = parseFloat(val.trim()) * parseInt(_peso) / 100;
81					if(peso > 0){
82						_this.attr('peso',peso);
83						
84					}else{
85						_this.attr('peso',0);
86					}
87					CalcolaSubTotali();
88				}
89			
90				break;
91			
92			default:
93				return true;
94		}
95
96	});
97	
98	
99	
100	CalcolaSubTotali = function(){
101		
102		var totale = 0;
103		var totale_pesi = 0;
104		
105		$("[peso]").each(function()
106		{
107			let _peso = $(this).attr('peso');			
108			if(_peso > 0){
109				
110				totale_pesi = parseFloat(totale_pesi) + parseFloat(_peso);
111				
112			}
113			
114		});
115		//alert(totale_pesi);
116		
117		$("[subtotale]").each(function()
118		{
119			let _attr = $(this).attr('data').split('|');
120			let _is_totale = _attr[0];
121			let _moltiplicatore = _attr[1];
122			let _percentuale = _attr[2];
123			subtotale = 0;			
124			
125			if(_is_totale == '1'){
126				
127				subtotale = totale;
128				
129			}else{
130				
131				if(_moltiplicatore > 0){
132				
133					subtotale = parseFloat(totale_pesi) * parseFloat(_moltiplicatore);
134				}
135				if(_percentuale > 0){
136				
137					subtotale = parseFloat(subtotale) * parseFloat(_percentuale) / 100;
138				}
139				
140				totale += subtotale;				
141				
142			}		
143			$(this).html(formatMoney(subtotale,2, DECIMALI, MIGLIAIA));
144		});
145		
146		
147	}
148	
149	$("[form-verifica]").submit(function(){
150		
151		let invia = true;
152		let id_box = $(this).attr('form-verifica');
153
154		$("[form-campo]").each(function()
155		{
156			let _attributo = $(this).attr('form-campo');
157			let _attr = _attributo.split('|');
158			let _id_box = _attr[0];
159			let _campo = _attr[1];
160			let _tipo = _attr[2];
161			let _obbligatorio = _attr[3];
162			let _campo_logico = _attr[4];
163			let _id_campo = _attr[6];
164			if(id_box == _id_box){
165				
166				let val = '';
167				let _error = $(this).attr('form-error');
168				switch(_tipo) {
169					
170					case 'text':
171					case 'textarea':
172					case 'data':
173					case 'native-data':
174						
175						val = $(this).val();
176						//alert(_campo+$(this).is(':visible'));
177						if(val.trim().length < numero_minimo && _obbligatorio == '1' && $(this).is(':visible')){
178							
179							if(last_error != _campo){
180								last_error = _campo;
181								alert('error '+_campo);
182							}
183							$(this).focus();
184							invia = false;
185							
186						}
187						break;
188						
189					case 'range':
190						
191						val = $(this).val();
192						if(val.trim().length < numero_minimo_range && _obbligatorio == '1' && $(this).is(':visible')){
193							
194							if(last_error != _campo){
195								last_error = _campo;
196								alert('error '+_campo);
197							}
198							$(this).focus();
199							invia = false;
200							
201						}
202						break;
203					
204					case 'select':
205						
206						val = $(this).val();
207						if(val.trim().length == 0 && _obbligatorio == '1' && $(this).is(':visible')){
208							
209							if(last_error != _campo){
210								last_error = _campo;
211								alert('error '+_campo);
212							}
213							$(this).focus();
214							invia = false;
215							
216						} 
217						break;
218					
219					case 'multiselect':
220						
221						selectedValues = $(this).val();
222						if($(this).is(':visible')){
223							if((selectedValues == null && _obbligatorio == '1') || (selectedValues != null && selectedValues.length == 0 && _obbligatorio == '1')){
224								
225								if(last_error != _campo){
226									last_error = _campo;
227									alert('error '+_campo);
228								}
229								$(this).focus();
230								invia = false;
231								
232							}
233						}
234						break;
235					
236					case 'checkbox':
237						
238						let checked = false;
239						if(_obbligatorio == '1' && $(this).is(':visible')){
240							
241							$("[form-campo]").each(function()
242							{
243								let _attributo_x = $(this).attr('form-campo');
244								if(_attributo_x == _attributo){
245									
246									let _checked = $(this).prop("checked");
247									if(_checked == true){
248										
249										checked = true;
250										
251									}
252									
253									
254								}
255								
256							});
257								
258							if(checked == false){
259									
260								if(last_error != _campo){
261									last_error = _campo;
262									alert('error '+_campo);
263								}
264								$(this).focus();
265								invia = false;
266								
267							} 
268							
269							
270						}	
271						break;
272					
273						
274					
275					case 'file':
276					case 'multifile':
277						
278						let quantifiles = $(this).attr('form-files');
279						val = $(this).val();
280						if(val.trim().length == 0 && _obbligatorio == '1' && quantifiles == 0 && $(this).is(':visible')){
281							
282							if(last_error != _campo){
283								last_error = _campo;
284								alert('error '+_campo);
285							}
286							$(this).focus();
287							invia = false;
288							
289						} 
290						break;
291						
292					case 'signature':
293								
294						let fattaFirma = $('#saveSignature_'+_id_campo).val();	
295						if(fattaFirma == '' && $(this).is(':visible')){
296							
297							if(last_error != _campo){
298								last_error = _campo;
299								alert('error '+_campo);
300							}
301							//$(this).focus();
302							invia = false;
303							
304						}
305						//var dataURL = canvas.toDataURL("image/png");
306						//$('#saveSignature').val(dataURL);
307						break;
308						
309					default:
310						return true;
311				}
312				if(_error != ''){
313						
314					alert(_error);
315					$(this).focus();
316					invia = false;
317											
318				}
319			}
320			
321		});
322		
323		if(typeof google_captcha !== 'undefined' && google_captcha === true){
324			
325			if(!eval('im_not_a_robot'+id_box))
326			{
327				alert("Clicca su 'Non sono un robot' per continuare");
328				invia = false;
329			}				
330			
331		}
332				
333		last_error = '';
334		
335		if(invia == false) return false;
336		
337		var response = window.confirm(testi_lingue['generale']['confermi']);
338		if (!response) return(false);
339		
340	});
341	
342	
343	$.datepicker.setDefaults($.datepicker.regional['it']);
344	$("[date]").datepicker({
345	
346		dateFormat: "dd/mm/yy",
347		changeMonth: true,
348		changeYear: true,	
349		yearRange: "-100:+20",
350		onSelect: function(dateText, inst) {
351			
352			let _this = $(this);
353			let _attr = _this.attr('form-campo').split('|');
354			let _campo = _attr[1];
355			let _tipo = _attr[2];
356			let _obbligatorio = _attr[3];
357			let _campo_logico = _attr[4];
358			
359			if(_campo_logico != ''){
360				
361				$.ajax({
362
363					type: "POST",
364					url: '/version_2/jfiles/form_verifica.php',
365					dataType: "json",
366					data: {
367						"type": _campo_logico,
368						"valore": dateText.trim(),
369					},
370					success: function(data) {
371						if(data.error != ''){
372							_this.attr('form-error',data.error);
373						}else{
374							_this.attr('form-error','');
375						}
376
377					},
378					error: function(data) { console.error(data); }
379
380				});
381				
382				
383			}
384			
385
386		}
387
388    });
389	
390	$('.ui-datepicker').addClass('notranslate');
391	
392	
393});
394
395
396function formatMoney(number, decPlaces, decSep, thouSep) {
397	decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
398	decSep = typeof decSep === "undefined" ? "." : decSep;
399	thouSep = typeof thouSep === "undefined" ? "," : thouSep;
400	var sign = number < 0 ? "-" : "";
401	var i = String(parseInt(number = Math.abs(Number(number) || 0).toFixed(decPlaces)));
402	var j = (j = i.length) > 3 ? j % 3 : 0;
403
404	return sign +
405		(j ? i.substr(0, j) + thouSep : "") +
406		i.substr(j).replace(/(\decSep{3})(?=\decSep)/g, "$1" + thouSep) +
407		(decPlaces ? decSep + Math.abs(number - i).toFixed(decPlaces).slice(2) : "");
408}

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.