<!--
  var formatoFecha = 'dd/mm/yyyy';	// Formato de fecha que vamos a utilizar
  
  // Función de validación de email
  function emailValido(valor) {
		var EmailOk = true;
		var AtSym = valor.indexOf('@');
		var Period = valor.lastIndexOf('.');
		var Space = valor.indexOf(' ');
		var Length = valor.length - 1;
		if ((AtSym < 1) || (Period <= AtSym+1) || (Period == Length ) || (Space  != -1)) {  
		  EmailOk = false;
		}
		return EmailOk;
  }
  
  // Función de validación de fecha
  function fechaValida(valor) {
  	var formatoFechaReg = formatoFecha;
  	formatoFechaReg = formatoFechaReg.replace('dd','([0-2][0-9]|3[0-1])');
  	formatoFechaReg = formatoFechaReg.replace('mm','(0[0-9]|1[0-2])');
  	formatoFechaReg = formatoFechaReg.replace(/y/g,'[0-9]');
  	formatoFechaReg = "^" + formatoFechaReg + "$";
  	var ExpReg = new RegExp(formatoFechaReg);
  	var fechaOK = ExpReg.test(valor);
  	return fechaOK;
  }
  
  function checkForm(frm) {
    for(i=0;i<frm.length;i++) {
    	campo = frm.elements[i];
    	if(campo.disabled)
    		continue;
    	var datosCheck = campo.id.split('#');
    	if(datosCheck[0].indexOf('*') != -1) {
    		if(campo.value == "") {
    			alert('No has rellenado el campo ' + datosCheck[1]);
    			campo.focus();
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('numero') != -1) {
    		if(isNaN(campo.value)) {
    			alert('El campo ' + datosCheck[1] + ' tiene que ser numérico');
    			campo.focus();
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('email') != -1) {
    		if(!emailValido(campo.value)) {
    			alert('El campo ' + datosCheck[1] + ' tiene que ser un email');
    			campo.focus();
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('fecha') != -1) {
    		if(!fechaValida(campo.value)) {
    			alert('El formato del campo ' + datosCheck[1] + ' no es válido');
    			campo.focus();
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('checkbox') != -1) {
    		if(campo.checked == false) {
    			alert('No has rellenado el campo ' + datosCheck[1]);
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('radio') != -1) {
    		var radioCheck = 0;
    		eval('var radioElemento = frm.' + campo.name);
    		for(j=0;j<radioElemento.length;j++) {
    			if(radioElemento[j].checked)
    				radioCheck = 1;
    		}
    		if(radioCheck == 0) {
    			alert('No has rellenado el campo ' + datosCheck[1]);
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('select') != -1) {
    		if(campo.selectedIndex == 0) {
    			alert('No has rellenado el campo ' + datosCheck[1]);
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('selectMultiple') != -1) {
    		seleccion = 0
    		for(j=1;j<campo.length;j++) {
    			if(campo.options[j].selected == true)
    				seleccion = 1
    		}
    		if(seleccion == 0) {
    			alert('No has rellenado el campo ' + datosCheck[1]);
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('select2Multiple') != -1) {
    		if(campo.length == 0) {
    			alert('No has rellenado el campo ' + datosCheck[1]);
    			return false;
    		}
    	}
    	var expReg = /[^A-Za-z0-9ñÑáéíóúÁÉÍÓÚüÜ_\s\¿\?\¡\!\<\>\.\,\:\;\(\)\@\#\$\€\%\&\\\/\*\=\+\-\{\}\[\]\ç\º\ª]/i;
    	if(datosCheck[0].indexOf('parsear') != -1) {
    		if(expReg.test(campo.value)) {
    			alert('El campo ' + datosCheck[1] + ' no es válido\n');
    			campo.focus();
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('min') != -1) {
    		posicion = datosCheck[0].indexOf('min') + 3;
    		limite = "0";
    		while((!isNaN(datosCheck[0].substring(posicion,posicion + 1))) && (posicion < datosCheck[0].length)) {
    			limite = limite + datosCheck[0].substring(posicion,posicion + 1);
    			posicion = posicion + 1;
    		}
    		limite = parseInt(limite,10);
    		if(campo.value.length < limite) {
    			alert('El campo ' + datosCheck[1] + ' tiene que tener al menos ' + limite + ' caracteres\n');
    			campo.focus();
    			return false;
    		}
    	}
    	if(datosCheck[0].indexOf('max') != -1) {
    		posicion = datosCheck[0].indexOf('max') + 3;
    		limite = "0";
    		while((!isNaN(datosCheck[0].substring(posicion,posicion + 1))) && (posicion < datosCheck[0].length)) {
    			limite = limite + datosCheck[0].substring(posicion,posicion + 1);
    			posicion = posicion + 1;
    		}
    		limite = parseInt(limite,10);
    		if(campo.value.length > limite) {
    			alert('El campo ' + datosCheck[1] + ' tiene que como máximo ' + limite + ' caracteres\n');
    			campo.focus();
    			return false;
    		}
    	}
    }
    return true;
  }
//-->