PageSourceSearch

https://seguro.fmdos.cl/js/validations/checkBornDate.js

js fmdos.cl collected 2026-09-24 09:12:21 UTC 4,778 bytes, 150 lines download raw bytes

1$(document).ready(function() {
2	$('#ug_boton_principal').click(function() {			
3		if (getObject("global_error_dtm")){
4			res = check_error_borndate_dtm(getObject("agno"), getObject("mes"), getObject("dia"));
5			if (res) return false;
6			else return true;
7		}
8		else{
9			res = check_error_borndate(getObject("agno"), getObject("mes"), getObject("dia"));
10			if (res) return errorGenerico('BornDate');
11			else return true;
12		}
13	});
14})	
15
16check_error_borndate = function(Year, Month, Day) {
17	var has_error = false;
18	//var info_Day = info_BornDate;
19	
20	//si no hay ningun campo relleno y no es obligatorio la damos por valida
21	if(Year.value == 0 && Month.value == 0 && Day.value == 0 && !obligatorio('BornDate')){
22		has_error= false;
23	}else{ 
24		if (Year.value == '0' || Month.value == '00' || Day.value == '0') {
25			muestraSelectError({campo:getObject('dia'),texto:borndateemptymsg});
26			muestraSelectError({campo:getObject('mes'),texto:''});
27			muestraSelectError({campo:getObject('agno'),texto:''});
28			has_error = true;
29		
30		}else if ( Year.value != '0' && Month.value != '00' && Day.value != '0' && menorEdad(Year.value, Month.value, Day.value, 14)){
31			muestraSelectError({campo:getObject('dia'),texto:borndateminmsg});
32			muestraSelectError({campo:getObject('mes'),texto:''});
33			muestraSelectError({campo:getObject('agno'),texto:''});
34			has_error = true;
35		}
36	}
37	return has_error;
38}
39
40menorEdad = function(Year, Month, Day, edad){
41    fechaActual = new Date();
42    
43    YearAct = fechaActual.getFullYear();
44    MonthAct = fechaActual.getMonth()+1; // los meses que devuelve el objeto Date van de 0 a 11
45    DayAct = fechaActual.getDate();
46
47    userAge = YearAct-Year;
48
49    if (MonthAct<Month){
50		userAge--;
51	}
52// caso especial: 29-02-AAAA y 28-02-BBBB se considerarán días iguales
53    else if (Month == MonthAct && Day<DayAct && MonthAct=='02' && DayAct=='29'){
54		userAge;
55	}
56    else if (Month == MonthAct && Day>DayAct){
57		userAge--;
58	}
59
60    if (userAge<edad){
61		return true;
62	}
63    else{
64		return false;
65	}
66}
67
68setPreferencias = function() {
69
70 var esMenorEdad;	
71 esMenorEdad = menorEdad(getObject('agno').value,getObject('mes').value,getObject('dia').value,'18');	
72 if(esMenorEdad){
73	 $('input:checkbox').each( function () {
74		   if($(this).attr('id') == 'terceros'){
75				$(this).prop('checked',false);
76		   }
77		   if($(this).attr('id').lastIndexOf('_c')>-1){
78				$(this).prop('checked',false);
79		   }
80		   if($(this).attr('id').lastIndexOf('_o')>-1){
81				$(this).prop('checked',true);
82		   }
83		   if($(this).attr('id') == 'ofertas'){
84				$(this).prop('checked',true);
85		   }
86		   if($(this).attr('id').lastIndexOf('nwl_')>-1){
87				$(this).prop('checked',true);
88		   }
89			
90		   if ( $("#info_boton_configurar").length > 0 ){	
91			 document.getElementById("ug_boton_principal").innerHTML= 'Continuar';  
92			 //$("#info_boton_configurar").hide();	
93		   }	
94		   
95		  });
96  }
97  else{
98	  $('input:checkbox').each( function () {
99		   if($(this).attr('id') == 'terceros'){
100				$(this).prop('checked',false);
101		   }
102		   if($(this).attr('id').lastIndexOf('_c')>-1){
103				$(this).prop('checked',false);
104		   }
105		   if($(this).attr('id').lastIndexOf('_o')>-1){
106				$(this).prop('checked',false);
107		   }
108		   if($(this).attr('id') == 'ofertas'){
109				$(this).prop('checked',false);
110		   }
111		   if($(this).attr('id').lastIndexOf('nwl_')>-1){
112				$(this).prop('checked',false);
113		   }			
114		  });
115		
116		  if ( $("#info_boton_configurar").length > 0 ){	
117			document.getElementById("ug_boton_principal").innerHTML= 'Aceptar todo y continuar';  
118			$("#info_boton_configurar").show();	
119		  }  
120	  
121  }  
122}
123
124check_error_borndate_dtm = function(Year, Month, Day) {
125	var has_error = false;
126	//var info_Day = info_BornDate;
127	
128	//si no hay ningun campo relleno y no es obligatorio la damos por valida
129	if(Year.value == 0 && Month.value == 0 && Day.value == 0 && !obligatorio('BornDate')){
130		has_error= false;
131	}else{ 
132		if (Year.value == '0' || Month.value == '00' || Day.value == '0') {
133			muestraSelectError({campo:getObject('dia'),texto:borndateemptymsg});
134			muestraSelectError({campo:getObject('mes'),texto:''});
135			muestraSelectError({campo:getObject('agno'),texto:''});
136			errorGenerico('BornDate:campo_vacio');
137			has_error = true;
138		
139		}else if ( Year.value != '0' && Month.value != '00' && Day.value != '0' && menorEdad(Year.value, Month.value, Day.value, 14)){
140			muestraSelectError({campo:getObject('dia'),texto:borndateminmsg});
141			muestraSelectError({campo:getObject('mes'),texto:''});
142			muestraSelectError({campo:getObject('agno'),texto:''});
143			errorGenerico('BornDate:menor_edad');
144			has_error = true;
145		}
146	}
147	return has_error;
148}
149
150

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.