function leadZero( xNumber ) { if( xNumber.length < 2 ) { xNumber = '0' + xNumber } return xNumber; } function checkYear(year) { return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0; } function checkDate( myDate ) { var months = new Array( ); months[ 0 ] = 31; months[ 1 ] = 28; months[ 2 ] = 31; months[ 3 ] = 30; months[ 4 ] = 31; months[ 5 ] = 30; months[ 6 ] = 31; months[ 7 ] = 31; months[ 8 ] = 30; months[ 9 ] = 31; months[ 10 ] = 30; months[ 11 ] = 31; x1 = 0; y = ''; z = ''; if ( myDate.length != 0 ) { x = myDate.indexOf( '/' ); if ( x < 0 ) { x = myDate.indexOf( '-' ) } if ( x < 0 && myDate.length == 8 ) { xDate = myDate.substring( 0, 4 ) + '/' + myDate.substring( 4, 6 ) + '/' + myDate.substring( 6, 8 ); myDate = xDate; x = myDate.indexOf( '/' ); } if ( x == 4 ) { y = myDate.substring( 0, x ); yNumber = parseInt( y, 10 ); if( !isNaN( yNumber ) && yNumber > 1900 ) { z = yNumber.toString() + '/'; if ( checkYear( yNumber ) ) { months[ 1 ] = 29; } x1 = myDate.indexOf( '/', x + 1 ) if ( x1 < 0 ) { x1 = myDate.indexOf( '-', x + 1 ) } if ( x1 >= (x + 2) && x1 <= (x + 3) ) { y = myDate.substring( x+1, x1 ); yNumber = parseInt( y, 10 ); if( !isNaN( yNumber ) && yNumber <= 12 && yNumber >= 1 ) { z = z + leadZero( yNumber.toString() ) + '/'; y = myDate.substring( x1+1, myDate.length ); yNumber = parseInt( y, 10 ); if( !isNaN( yNumber ) && yNumber <= months[ parseInt( z.substring( 5, 7 ), 10 ) - 1 ] && yNumber >= 1 ) { z = z + leadZero( yNumber.toString() ); } } } } } if ( z.length < 10 ) { z = ''; } } return z; } var cValidChars = "abcdefghijklmnñopqrstuvwxyzáéíóú "; var cValidData = "abcdefghijklmnñopqrstuvwxyzáéíóú 0123456789#/,*."; var cValidDataCCT = 'abcdefghijklmnñopqrstuvwxyzáéíóú 0123456789#/,*."'; var cValidLTGTitulo = 'abcdefghijklmnñopqrstuvwxyzáéíóú 0123456789#/,*."-'; var cValidLTGClave = 'abcdefghijklmnñopqrstuvwxyz0123456789-'; var cValidRFC = "abcdefghijklmnñopqrstuvwxyz0123456789"; var cValidCharNumber = "abcdefghijklmnñopqrstuvwxyzáéíóú 0123456789"; var cValidNumbers = "0123456789"; var cValidARC = "earc0123456789"; var cValidNames = "abcdefghijklmnñopqrstuvwxyzü " var cValidGrades = "0123456789." var cValidGradesInt = "0123456789" function ValidText( xTexto, xSetCaracteres ) { var xCtrl = 0; var xTxt = xTexto.toLowerCase(); var xTxtLast = xTxt.charAt( 0 ); xTexto = ''; while ( xCtrl < xTxt.length ) { if ( xSetCaracteres.indexOf( xTxt.charAt( xCtrl ) ) > -1 ) { xTexto = xTexto + xTxt.charAt( xCtrl ); xTxtLast = xTxt.charAt( xCtrl ); } xCtrl++; } return( xTexto ); } function ValidCantidad( xCantidad ) { xCantidad = ValidInput( xCantidad, cValidNumbers ); if ( xCantidad.length > 1 ) { while( xCantidad.charAt( 0 ) == '0' ) { xCantidad = xCantidad.substring( 1, xCantidad.length ); } } if ( xCantidad.length == 0 ) { xCantidad='0'; } return( xCantidad ); } function ValidInput( xTexto, xSetCaracteres ) { var xCtrl = 0; var xTextoAux = ''; var xTxt = xTexto.toLowerCase(); var xTxtLast = xTxt.charAt( 0 ); xTexto = ''; while ( xCtrl < xTxt.length ) { if ( xSetCaracteres.indexOf( xTxt.charAt( xCtrl ) ) > -1 ) { if ( xTxtLast.charAt( 0 ) == ' ' && xTxt.charAt( xCtrl ) == ' ' ) { } else { xTexto = xTexto + xTxt.charAt( xCtrl ); xTxtLast = xTxt.charAt( xCtrl ); } } xCtrl++; } while ( xTexto.charAt( 0 ) == ' ' ) { xTexto = xTexto.substring( 1, xTexto.length ); } while ( xTexto.charAt( xTexto.length - 1 ) == ' ' ) { xTexto = xTexto.substring( 0, xTexto.length - 1 ); } return( xTexto.toUpperCase() ); } function ValidValueMinMax( xTexto, xMin, xMax ) { xTexto = ValidInput( xTexto, cValidNumbers ); if ( isNaN( parseInt( xTexto ) ) ) { xTexto = ''; } else { if ( ( parseInt( xTexto ) >= parseInt( xMin ) ) && ( parseInt( xTexto ) <= parseInt( xMax ) ) ) { } else { alert( xTexto + ' no esta entre ' + xMin + ' y ' + xMax + '\npor lo tanto no es un ciclo válido.' ); xTexto = ''; } } return ( xTexto ); } function ValueMinMax( xTexto, xMin, xMax ) { xTexto = ValidInput( xTexto, cValidNumbers ); if ( isNaN( parseInt( xTexto ) ) ) { xTexto = ''; } else { if ( ( parseInt( xTexto ) >= parseInt( xMin ) ) && ( parseInt( xTexto ) <= parseInt( xMax ) ) ) { } else { alert( xTexto + ' no esta entre ' + xMin + ' y ' + xMax ); xTexto = xMin; } } return ( xTexto ); } function ValidGrade( xTexto ) { xTexto = ValidInput( xTexto, cValidGrades ) while ( xTexto.charAt( 0 ) == '0' ) { xTexto = xTexto.substring( 1, xTexto.length ); } while ( xTexto.charAt( xTexto.length - 1 ) == '.' ) { xTexto = xTexto.substring( 0, xTexto.length - 1 ); } if ( isNaN( parseFloat( xTexto ) ) ) { xTexto = '0'; } else { if ( ( parseFloat( xTexto ) >= 5.0 && parseFloat( xTexto ) <= 10.0 ) || ( parseFloat( xTexto ) == 0 ) ) { if ( parseFloat( xTexto ) < 10.0 && parseFloat( xTexto ) >= 5.0 && xTexto.length > 3 ) { xTexto = xTexto.substring( 0, 3 ); } } else { if ( parseInt( xTexto ) >= 50 && parseInt( xTexto ) <= 100 ) { if ( parseInt( xTexto ) == 100 ) { xTexto = '10'; } else { xTexto = xTexto.charAt( 0 ) + '.' + xTexto.charAt( 1 ); } } else { alert( 'La calificación debe ser mayor o igual a 5.0 y menor o igual a 10.0' ); xTexto = '0'; } } } return( xTexto ) } function ValidGradeOBJ( xObjeto ) { xResultado = true; xTexto = ValidInput( xObjeto.value, cValidGrades ) while ( xTexto.charAt( 0 ) == '0' ) { xTexto = xTexto.substring( 1, xTexto.length ); } while ( xTexto.charAt( xTexto.length - 1 ) == '.' ) { xTexto = xTexto.substring( 0, xTexto.length - 1 ); } if ( isNaN( parseFloat( xTexto ) ) ) { xTexto = '0'; } else { if ( ( parseFloat( xTexto ) >= 5.0 && parseFloat( xTexto ) <= 10.0 ) || ( parseFloat( xTexto ) == 0 ) ) { if ( parseFloat( xTexto ) < 10.0 && parseFloat( xTexto ) >= 5.0 && xTexto.length > 3 ) { xTexto = xTexto.substring( 0, 3 ); } } else { if ( parseInt( xTexto ) >= 50 && parseInt( xTexto ) <= 100 ) { if ( parseInt( xTexto ) == 100 ) { xTexto = '10'; } else { xTexto = xTexto.charAt( 0 ) + '.' + xTexto.charAt( 1 ); } } else { alert( 'La calificación debe ser mayor o igual a 5.0 y menor o igual a 10.0' ); xTexto = '0'; xResultado = false; } } } if ( parseFloat( xTexto ) >= 5.0 && parseFloat( xTexto ) < 6.0 ) { xObjeto.style.background = '#ff0000'; xObjeto.style.color = '#FFFFFF'; } else { if ( parseFloat( xTexto ) >= 6.0 ) { xObjeto.style.background = '#ffffff'; xObjeto.style.color = '#000000'; } else { xObjeto.style.background = '#F9FABB'; xObjeto.style.color = '#000000'; } } xObjeto.value = xTexto; if ( xResultado ) { return( true ); } else { xObjeto.focus(); xObjeto.select(); } } function ValidGradeOBJint( xObjeto ) { xResultado = true; xTexto = ValidInput( xObjeto.value, cValidGradesInt ) while ( xTexto.charAt( 0 ) == '0' ) { xTexto = xTexto.substring( 1, xTexto.length ); } while ( xTexto.charAt( xTexto.length - 1 ) == '.' ) { xTexto = xTexto.substring( 0, xTexto.length - 1 ); } if ( isNaN( parseInt( xTexto ) ) ) { xTexto = '0'; } else { if ( ( parseInt( xTexto ) >= 5 && parseInt( xTexto ) <= 10 ) || ( parseInt( xTexto ) == 0 ) ) { if ( parseInt( xTexto ) < 10 && parseInt( xTexto ) >= 5 && xTexto.length > 2 ) { xTexto = xTexto.substring( 0, 2 ); } } else { alert( 'La calificación debe ser mayor o igual a 5 y menor o igual a 10' ); xTexto = '0'; xResultado = false; } } if ( parseInt( xTexto ) >= 5 && parseInt( xTexto ) < 6 ) { xObjeto.style.background = '#ff0000'; xObjeto.style.color = '#FFFFFF'; } else { if ( parseInt( xTexto ) >= 6 ) { xObjeto.style.background = '#ffffff'; xObjeto.style.color = '#000000'; } else { xObjeto.style.background = '#F9FABB'; xObjeto.style.color = '#000000'; } } xObjeto.value = xTexto; if ( xResultado ) { return( true ); } else { xObjeto.focus(); xObjeto.select(); } } function ValidTextAccents( xTexto, xSetCaracteres ) { var xCtrl = 0; var xTxt = xTexto.toLowerCase(); xTxt = xTxt.replace("á","a"); xTxt = xTxt.replace("é","e"); xTxt = xTxt.replace("í","i"); xTxt = xTxt.replace("ó","o"); xTxt = xTxt.replace("ú","u"); var xTxtLast = xTxt.charAt( 0 ); xTexto = ''; while ( xCtrl < xTxt.length ) { if ( xSetCaracteres.indexOf( xTxt.charAt( xCtrl ) ) > -1 ) { xTexto = xTexto + xTxt.charAt( xCtrl ); xTxtLast = xTxt.charAt( xCtrl ); } xCtrl++; } return( xTexto ); } function checkDateLimited( myDate, minDate, maxDate ) { var months = new Array( ); months[ 0 ] = 31; months[ 1 ] = 28; months[ 2 ] = 31; months[ 3 ] = 30; months[ 4 ] = 31; months[ 5 ] = 30; months[ 6 ] = 31; months[ 7 ] = 31; months[ 8 ] = 30; months[ 9 ] = 31; months[ 10 ] = 30; months[ 11 ] = 31; x1 = 0; y = ''; z = ''; if ( myDate.length != 0 ) { x = myDate.indexOf( '/' ); if ( x < 0 ) { x = myDate.indexOf( '-' ) } if ( x < 0 && myDate.length == 8 ) { xDate = myDate.substring( 0, 4 ) + '/' + myDate.substring( 4, 6 ) + '/' + myDate.substring( 6, 8 ); myDate = xDate; x = myDate.indexOf( '/' ); } if ( x == 4 ) { y = myDate.substring( 0, x ); yNumber = parseInt( y, 10 ); if( !isNaN( yNumber ) && yNumber > 1900 ) { z = yNumber.toString() + '/'; if ( checkYear( yNumber ) ) { months[ 1 ] = 29; } x1 = myDate.indexOf( '/', x + 1 ) if ( x1 < 0 ) { x1 = myDate.indexOf( '-', x + 1 ) } if ( x1 >= (x + 2) && x1 <= (x + 3) ) { y = myDate.substring( x+1, x1 ); yNumber = parseInt( y, 10 ); if( !isNaN( yNumber ) && yNumber <= 12 && yNumber >= 1 ) { z = z + leadZero( yNumber.toString() ) + '/'; y = myDate.substring( x1+1, myDate.length ); yNumber = parseInt( y, 10 ); if( !isNaN( yNumber ) && yNumber <= months[ parseInt( z.substring( 5, 7 ), 10 ) - 1 ] && yNumber >= 1 ) { z = z + leadZero( yNumber.toString() ); } } } } } if ( z.length < 10 ) { z = ''; } if ( z.length == 10 ) { if( z >= minDate && z<=maxDate ) { } else { alert( 'Según la normatividad, para inscribir a un niño en el grado seleccionado\nla fecha de nacimiento debe ser entre ' + minDate + ' y ' + maxDate ); z = ''; } } else { alert('La Fecha proporcionada no es valida.') } } return z; } function txtRelated( xSource, xTarget ) { xTarget.value = xSource.value; } function selRelated( xSource, xTarget ) { if ( xTarget.value != xSource.value ) { xCtrl = -1; while ( ++xCtrl < xTarget.length ) { if ( xTarget[ xCtrl ].value == xSource.value ) { xTarget[ xCtrl ].selected = true; xTarget.value = xSource.value; xCtrl = xTarget.length; } } if ( xTarget.value != xSource.value ) { xSource.value = xTarget.value } } } function selRelatedExtended( xSource, xTarget, xRelated, xRelatedMsg, curMsg ) { if ( xTarget.value != xSource.value ) { xCtrl = -1; while ( ++xCtrl < xTarget.length ) { if ( xTarget[ xCtrl ].value == xSource.value ) { xTarget[ xCtrl ].selected = true; xTarget.value = xSource.value; xCtrl = xTarget.length; } } if ( xTarget.value != xSource.value ) { xSource.value = xTarget.value } else { xRelated.value = 0; xRelatedMsg.value = curMsg; } } } function valRelMinMax( xSelf, xOther, xMin, xMax ) { xSelf.value = ValidInput( xSelf.value, cValidNumbers ); if ( xSelf.value.length == 0 ) { xSelf.value = xMin; xOther.value = xMax; } else { if ( (parseInt( xSelf.value ) >= xMin) && (parseInt( xSelf.value ) <= xMax) ) { if ( xOther.value.length == 0 ) { xOther.value = xSelf.value } else { if ( parseInt( xOther.value ) < parseInt( xSelf.value ) ) { xOther.value = xSelf.value } } } else { if ( parseInt( xSelf.value ) > xMin ) { xSelf.value = xMax; xOther.value = xMax; } else { xSelf.value = xMin; } } } } function valRelMaxMin( xSelf, xOther, xMin, xMax ) { xSelf.value = ValidInput( xSelf.value, cValidNumbers ); if ( xSelf.value.length == 0 ) { xSelf.value = xMax; xOther.value = xMin; } else { if ( (parseInt( xSelf.value ) >= xMin) && (parseInt( xSelf.value ) <= xMax) ) { if ( xOther.value.length == 0 ) { xOther.value = xSelf.value } else { if ( parseInt( xOther.value ) > parseInt( xSelf.value ) ) { xOther.value = xSelf.value } } } else { if ( parseInt( xSelf.value ) > xMax ) { xSelf.value = xMax; xOther.value = xMin; } else { xSelf.value = xMax; } } } } function getRadioValNoForm( name) { var val; var radios = document.getElementsByName(name); for (var i=0, len=radios.length; i