Foros del Web » Programando para Internet » Javascript »

Problemas con validacion de formulario php / javascript

Estas en el tema de Problemas con validacion de formulario php / javascript en el foro de Javascript en Foros del Web. Hola gente como estan? gracias por leer mi post, en estos momentos tengo un problema con una validacion de elementos seleccionados en un select, aca ...
  #1 (permalink)  
Antiguo 08/03/2011, 14:32
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 15 años, 4 meses
Puntos: 19
Busqueda Problemas con validacion de formulario php / javascript

Hola gente como estan? gracias por leer mi post, en estos momentos tengo un problema con una validacion de elementos seleccionados en un select, aca tengo el script para que vean que pasa, me funciona todo excepto la que comprueba los combos. Saludos

Código HTML:
<script type="text/javascript">
//Validacion de Registro
function validar_registro() 
{
		var use1 = document.getElementById('username');
		var pas1 = document.getElementById('password1');
		var pas2 = document.getElementById('password2');
		var nomb = document.getElementById('nombres');
		var apel = document.getElementById('apellidos');
		var corr = document.getElementById('correo');
		var dire = document.getElementById('direccion');
		var tele = document.getElementById('telefono');
			
		var regreso = false;
		
		if(notEmpty("<?php echo $v_linea1; ?>",use1,"<?php echo $v_linea2; ?>")) {
		if(notEmpty("<?php echo $v_linea3; ?>",pas1,"<?php echo $v_linea4; ?>")) {
		if(notEmpty("<?php echo $v_linea3; ?>",pas2,"<?php echo $v_linea5; ?>")) {
		if(confirmar_claves("<?php echo $v_linea6; ?>", pas1, pas2, "<?php echo $v_linea7; ?>")) {
		if(notEmpty("<?php echo $v_linea8; ?>",nomb,"<?php echo $v_linea9; ?>")) {
		if(notEmpty("<?php echo $v_linea10; ?>",apel,"<?php echo $v_linea11; ?>")) {
		if(notEmpty("<?php echo $v_linea12; ?>",corr,"<?php echo $v_linea13; ?>")) {
		if(emailValidator("<?php echo $v_linea14; ?>", corr, "<?php echo $v_linea15; ?>")) {
		if(notEmpty("<?php echo $v_linea16; ?>",dire,"<?php echo $v_linea17; ?>")) {
		if(notEmpty("<?php echo $v_linea18; ?>",tele,"<?php echo $v_linea19; ?>")) {
		if(isNumeric("<?php echo $v_linea20; ?>", tele, "<?php echo $v_linea21; ?>")) {
		if(lengthRestriction_specific("<?php echo $v_linea22; ?>", tele, 11, "<?php echo $v_linea23; ?>")) {
		if(chequeo_boxes()) {
		
		return true;
		
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}
		

		
		return false;
		
}

function chequeo_boxes() {
	
	if (document.form1.tipo.checked) {
			
		var cedu = document.getElementById('documento');
		var nomt = document.getElementById('nombrecuenta');
		var banc = document.getElementById('idbanco');
		var tipo1 = document.getElementById('tipocuenta');
		var numc = document.getElementById('nocuenta');
		
		
		if(notEmpty("<?php echo $v_linea24; ?>",cedu,"<?php echo $v_linea25; ?>")) {
		if(notEmpty("<?php echo $v_linea34; ?>",nomt,"<?php echo $v_linea35; ?>")) {
		if(madeSelection("<?php echo $v_linea27; ?>", banc, "<?php echo $v_linea26; ?>", "<?php echo $linea21; ?>")) {
		if(madeSelection("<?php echo $v_linea27; ?>", tipo1, "<?php echo $v_linea28; ?>", "<?php echo $linea21; ?>")) {
		if(notEmpty("<?php echo $v_linea29; ?>",numc,"<?php echo $v_linea30; ?>")) {
		if(isNumeric("<?php echo $v_linea31; ?>", numc, "<?php echo $v_linea32; ?>")) {
		if(lengthRestriction_specific("<?php echo $v_linea31; ?>", numc, 20, "<?php echo $v_linea33; ?>")) {
					
		return true;
		
		}
		}
		}
		}
		}
		}
		}
		
		return false;
		
	} else {
		return true;
	}
}


</script> 
Y aca las funciones para validar

Código HTML:
//Funciones de Formularios
function notEmpty(titulo, elem, helperMsg){
	if(elem.value.length == 0){
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
/*		alert(helperMsg);
		elem.focus(); // set the focus to this input */
		return false;
	}
	return true;
}

function isNumeric(titulo, elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}
}

function isAlphabet(titulo, elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}
}

function isAlphanumeric(titulo, elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}
}

function lengthRestriction(titulo, elem, min, max, helperMsg){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}
}

function lengthRestriction_specific(titulo, elem, cant, helperMsg){
	var uInput = elem.value;
	if(uInput.length == cant){
		return true;
	}else{
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}
}

function madeSelection(titulo, elem, helperMsg, stringseleccionado){
	if(elem.value == stringseleccionado){
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}else{
		return true;
	}
}

function emailValidator(titulo, elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}
}

function archivos(titulo, elem, helperMsg, tipos) {
	extArray = new Array(tipos);
	function LimitAttach(form, file) {
		allowSubmit = false;
		if (!file) return;
		while (file.indexOf("\\") != -1)
			file = file.slice(file.indexOf("\\") + 1);
			ext = file.slice(file.indexOf(".")).toLowerCase();
			for (var i = 0; i < extArray.length; i++) {
				if (extArray[i] == ext) { allowSubmit = true; break; }
			}
		if (allowSubmit) form.submit();
		else
			Ext.MessageBox.alert(titulo, helperMsg, function() { Ext.get(elem).focus(); });
	}
}

function confirmar_claves(titulo, elem1, elem2, helperMsg) {
	if (elem1.value == elem2.value) {
		return true;
	} else {
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        	Ext.get(elem2).focus();
    	});
		return false;
	}
}

function confirmacion(titulo, helperMsg){
    Ext.MessageBox.confirm(titulo, helperMsg, showResult);
	if (showResult='YES') { 
		return true; 
	} else { 
		return false; 
	}
}

function closer() {
	var ventana = window.self;
	ventana.opener = window.self;
	ventana.close();
} 
__________________
http://www.solucionesrios.tk/

Visita mi Web!
  #2 (permalink)  
Antiguo 08/03/2011, 15:03
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 9 meses
Puntos: 1532
Respuesta: Problemas con validacion de formulario php / javascript

¿y según tu: cual es la que valida combos? ¿donde están, que contienen y que deberían validar?, además no se les llama combos, se llaman select
__________________
¡Por favor!: usa el highlight para mostrar código
El que busca, encuentra...
  #3 (permalink)  
Antiguo 08/03/2011, 19:20
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 15 años, 4 meses
Puntos: 19
Respuesta: Problemas con validacion de formulario php / javascript

Esta es la funcion de javascript que "Deberia" validar los select

Código:
function madeSelection(titulo, elem, helperMsg, stringseleccionado){
	if(elem.value == stringseleccionado){
		Ext.MessageBox.alert(titulo, helperMsg, function() {
        Ext.get(elem).focus();
    });
		return false;
	}else{
		return true;
	}
}
y aqui en esta la estoy llamando con unos valores dinamicos y no hace caso:(

Código:
function chequeo_boxes() {
	
	if (document.form1.tipo.checked) {
			
		var cedu = document.getElementById('documento');
		var nomt = document.getElementById('nombrecuenta');
		var banc = document.getElementById('idbanco');
		var tipo1 = document.getElementById('tipocuenta');
		var numc = document.getElementById('nocuenta');
		
		
		if(notEmpty("<?php echo $v_linea24; ?>",cedu,"<?php echo $v_linea25; ?>")) {
		if(notEmpty("<?php echo $v_linea34; ?>",nomt,"<?php echo $v_linea35; ?>")) {
		if(madeSelection("<?php echo $v_linea27; ?>", banc, "<?php echo $v_linea26; ?>", "<?php echo $linea21; ?>")) {
		if(madeSelection("<?php echo $v_linea27; ?>", tipo1, "<?php echo $v_linea28; ?>", "<?php echo $linea21; ?>")) {
		if(notEmpty("<?php echo $v_linea29; ?>",numc,"<?php echo $v_linea30; ?>")) {
		if(isNumeric("<?php echo $v_linea31; ?>", numc, "<?php echo $v_linea32; ?>")) {
		if(lengthRestriction_specific("<?php echo $v_linea31; ?>", numc, 20, "<?php echo $v_linea33; ?>")) {
					
		return true;
		
		}
		}
		}
		}
		}
		}
		}
		
		return false;
		
	} else {
		return true;
	}
}
__________________
http://www.solucionesrios.tk/

Visita mi Web!

Etiquetas: php, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:26.