Foros del Web » Programando para Internet » Jquery »

Código JQuery no carga

Estas en el tema de Código JQuery no carga en el foro de Jquery en Foros del Web. Hola, resulta que tengo este script en JQuery, pero no me funciona, no carga la página. No tengo mucha idea de Javascript, por lo que ...
  #1 (permalink)  
Antiguo 23/11/2010, 12:04
 
Fecha de Ingreso: enero-2008
Mensajes: 37
Antigüedad: 16 años, 3 meses
Puntos: 0
Exclamación Código JQuery no carga

Hola, resulta que tengo este script en JQuery, pero no me funciona, no carga la página. No tengo mucha idea de Javascript, por lo que no encuentro el fallo.
Código:
$(function(){
$.fn.checkRepetition = checkRepetition(pLen,str) {
	var res = "";
	for ( i=0; i<str.length ; i++ ) {
		repeated=true;
		for (j=0;j < pLen && (j+i+pLen) < str.length;j++)
		{
			repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen));
		}
		if (j<pLen) {repeated=false;}
		if (repeated) {
			i+=pLen-1;
			repeated=false;
		}
		else {
			res+=str.charAt(i);
		}
	}
	return res;
}

$.fn.pass_strenght = pass_strenght(password)
{
	var score = 0;

	if (password.length < 8 || !(/\d/.test(password))) { return 0; }

	score += password.length * 4;
	score += ( checkRepetition(1,password).length - password.length ) * 1;
	score += ( checkRepetition(2,password).length - password.length ) * 1;
	score += ( checkRepetition(3,password).length - password.length ) * 1;
	score += ( checkRepetition(4,password).length - password.length ) * 1;

	if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) { score += 5; }
	if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) { score += 5; }
	if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) { score += 10; }
	if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) { score += 15; }
	if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) { score += 15; }
	if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) { score += 15; }
	if (password.match(/^\w+$/) || password.match(/^\d+$/) ) { score -= 10; }
	if (score > 100) { return 100; }
	if (score < 0) { return 0; }

	return score;
}

	correct_img		= '<?php echo img($correct); ?>';
	compare_img		= '<?php echo $comp_img; ?>';
	wrong_img		= '<?php echo img($wrong); ?>';
	$('#submit').attr('disabled', true);

	$('#username').focus(function() {
		$('#user_result').html('');
	});
	$('#username').bind('blur keyup',function() {
		$('#user_result').html(correct_img);
	});
	$('#password').focus(function() {
		$('#pass_result').html('');
	});
	$('#password').bind('blur keyup',function() {
		var password		= $(this).val(),
			pass_conf		= $('#pass_conf').val(),
			username		= $('#username').val();

		if (password.toLowerCase() == username.toLowerCase() || pass_strenght(password) == 0)
		{
			$('#pass_result').html(wrong_img);
		}
		else
		{
			$('#pass_result').html(correct_img);
			$('#percent').style.width	= pass_strenght(password)+'%';
		}
		if(password == pass_conf && password && pass_conf) {
			$('#passconf_result').html(correct_img);
		}
	});
	$('#pass_conf').bind('blur keyup',function() {
		var password		= $('#password').val(),
			pass_conf		= $(this).val();

		if(password == pass_conf && password && pass_conf) {
			$('#passconf_result').html(correct_img);
		}
		else
		{
			$('#passconf_result').html(wrong_img);
		}
	});
	$('#email').focus(function() {
		$('#email_result').html('');
	});
	$('#email').bind('blur keyup', function() {
		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
		if(pattern.test($(this).val()))
		{
			$('#email_result').html(correct_img);
		}
		else
		{
			$('#email_result').html(wrong_img);
		}
	});
	$('input').focus(function() {
		$('#submit').attr('disabled', true);
	});
	$('input').bind('blur keyup', function() {
		if($("#user_result").html() != compare_img || $("#pass_result").html() != compare_img || $("#passconf_result").html() != compare_img || $("#email_result").html() != compare_img) {
			$('#submit').attr('disabled', true);
		}
		else
		{
			$('#submit').removeAttr('disabled');
		}
	});
	$('#submit').submit(function() {
		$('#submit').attr('disabled', true);
	});
});
  #2 (permalink)  
Antiguo 23/11/2010, 13:37
Avatar de mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: Código JQuery no carga

Fijate si IE te da algun error. Eso se ve abajo a la izquierda, en una alerta amarilla.

Otra opcion, mas avanzada, es usar un debugger como el firebug de firefox.
  #3 (permalink)  
Antiguo 23/11/2010, 14:12
 
Fecha de Ingreso: enero-2008
Mensajes: 37
Antigüedad: 16 años, 3 meses
Puntos: 0
Respuesta: Código JQuery no carga

Uso firebug, pero me dice que el javascript se ha desactivado al cargar la página.
  #4 (permalink)  
Antiguo 23/11/2010, 15:26
 
Fecha de Ingreso: enero-2008
Mensajes: 37
Antigüedad: 16 años, 3 meses
Puntos: 0
Respuesta: Código JQuery no carga

He revisado el tema, y lo he solucionado. Las funciones no estaban bien instanciadas.

Etiquetas: carga
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 16:02.