Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/05/2005, 03:46
Avatar de tunait
tunait
Moderadora
 
Fecha de Ingreso: agosto-2001
Ubicación: Terok Nor
Mensajes: 16.805
Antigüedad: 23 años, 6 meses
Puntos: 381
Buenas,

La función Trim() no existe en javascript pero hice una función que devuelve el mismo resultado.

Lo que tampoco existe en javascript es la función md5() pero ahí yá no he querido entrar (demasiao lío )

He visto que hay por la red scripts en js para simular esta función y devolver lo mismo, te sugiero lo agregues a tu código fuente.

Busca en google por +md5 +javascript

aquí un ejemplo http://pajhome.org.uk/crypt/md5/

si no agregas una función js de nombre MD5 te devolverá error. El resto debería funcionar sin problemas.

Código:
<script type="text/javascript">
function Trim(texto){
	espacio = " "
	esp = false
	if(texto.charAt(0) == espacio){
		texto = texto.substr(1)
		esp = true
	}
	if(texto.charAt(texto.length-1) == espacio){
		texto = texto.substring(0,texto.length-1)
		esp = true
	}
	if(esp){
		Trim(texto)
	}
	else{return texto}
}
function validar_clave(){
	var clave1, clave2
	clave1 = Trim(document.getElementById("claveuno").value)
	clave2 = Trim(document.getElementById("clavedos").value)
	var er, temp
	temp = false
	if (clave1.length > 3 && clave1.length < 21){
		er = RegExp("^[a-z0-9]+$","i")
		temp = er.test(clave1)
		if(temp && (clave1 != clave2)){
			temp = false
			alert("Las claves ingresadas no son iguales!")
			return false
		}
		if(!temp){
			alert("Las claves ingresadas no son correctas o tienen espacios en blanco!")
			return false
		}
		if (temp){
			document.getElementById("md5clave").value = MD5(clave1)
			document.getElementById("claveuno").value = ""
			document.getElementById("clavedos").value = ""
		}
		er = null
	}
	else{
		alert("Las claves ingresadas no son correctas o estan en blanco!")
	}
	validar_clave = temp
}
function validar(){
	valido = false
	if (validar_mail){
		if (validar_clave){valido = true}
	else
		alert("El email ingresado no es valido o esta en blanco!")
	}
	validar = valido
}
function validar_mail(){
	var bValido, Mail
	bValido = true
	Mail = Trim(document.getElementById("correo").value)
	if(Mail.length < 5){
		bValido = False
	}
	else{
		if(Mail.indexOf("@") > 0){
			bValido = false
		}
		else{
			if(Mail.indexOf(".") > 0){
				bValido = false
			}
			else{
				if(Mail.indexOf(".") < Mail.indexOf("@")){
					bValido = false
				}
			}
		}
	}
	
	validar_mail = bValido
}

</script>
Un saludo

Última edición por tunait; 21/05/2005 a las 03:53