Foros del Web » Programando para Internet » Javascript »

problema con recaptcha y javascript

Estas en el tema de problema con recaptcha y javascript en el foro de Javascript en Foros del Web. problema con recaptcha bueno mi problema es el siguiente espero puedan ayudarme a resolverlo tengo un formulario el cual valido con javascript hasta ahi todo ...
  #1 (permalink)  
Antiguo 16/08/2011, 15:21
 
Fecha de Ingreso: julio-2011
Ubicación: donde me encuentre la noche
Mensajes: 140
Antigüedad: 12 años, 8 meses
Puntos: 3
Pregunta problema con recaptcha y javascript

problema con recaptcha
bueno mi problema es el siguiente espero puedan ayudarme a resolverlo
tengo un formulario el cual valido con javascript hasta ahi todo bien (validar q
el campo no este vacio, que se introduzcan datos validos etc)
por ejemplo si no se introduce datos en un campo por medio de
javascript le notifico al usuario que no ha introducido dicho campo
y con un setfocus lo posiciono dentro de el campo que se requiere
todo esto lo hago llamando una funcion de javascript mediante el evento onsubmit del formulario
ahora el problema es q al meter el captcha dentro de dicho formulario no me verifica si las
palabras introducidas son correctas, o si dicho campo esta vacio o no.

como puedo hacer para q el captcha me notifique q se deben de ingresar las palabras y de igual forma
q me diga si dichas palabras son incorrectas dentro de un mensaje enviado por javascript


mi css
------------------------
@charset "utf-8";
/* CSS Document */

#formulario_registro {
height:530px;
width:400px;
position:absolute;
z-index:7;
top:49px;
left:476px;
background-color: #E6E4E3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}

#head_form{
background-color:#DEDBDF;
width:400px;
height:30px;
border-bottom-width: thin;
border-bottom-style: solid;
border-bottom-color: #CCCCCC;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
#titulo_form {
background-color:#C4C4C4;
height:30px;
width:300px;
-webkit-border-top-left-radius: 10px;
-moz-border-radius-topleft: 10px;
border-top-left-radius: 10px;
position:relative;
float:left;
text-align: center;
font-size: 24px;
border-right-width: thin;
border-right-style: solid;
border-right-color: #999999;
}
#close {
height:30px;
width:99px;
float:right;
position:relative;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topright: 10px;
border-top-right-radius: 10px;
text-align: right;
font-size: 16px;
}
#close1 {
position:relative;
float:right;
height:16px;
width:16px;
background-image:url(../imagenes/eliminar.png);
background-repeat:no-repeat;
background-color:#AEAEAE;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
border: thin solid #999999;
}

#formulario1{
width:365px;
margin:0 auto;
height:480px;
border-right-width: thin;
border-left-width: thin;
border-right-style: solid;
border-left-style: solid;
border-right-color: #CCCCCC;
border-left-color: #CCCCCC;
}

#Name, #Email, #Lastname, #Phone, #Password, #Password2 {
width:355px;
height:22px;
border: thin solid #990033;
-webkit-border-radius: 5px;
-moz-border-radius:5px;
border-radius: 5px;
}

#Phone {
width:165px;
height:22px;
border: thin solid #990033;
-webkit-border-radius: 5px;
-moz-border-radius:5px;
border-radius: 5px;
}

#resultado {
background-color:#CCCCCC;
color:#000000;
width:500px;
height:80PX;
position:absolute;
right:230px;
z-index:8;
top:476px;
text-align: center;
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
font-style: italic;
font-weight: bold;
}
------------------------------------------------------------------
mi php prueba.php
------------------------------------------------------------------
<?php
error_reporting ( E_ERROR );

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<script src="../js/jquery-1.6.min.js" type="text/javascript"></script>
<script type="text/javascript">
function validar_tel(valor){
// creamos nuestra regla con expresiones regulares.
var filter1 =/^[0-9]{2,3}-? ?[0-9]{6,7}$/;
// utilizamos test para comprobar si el parametro valor cumple la regla
if(filter1.test(valor))
return true;
else
return false;
}

function validar_email(valor){
// creamos nuestra regla con expresiones regulares.
var filter = /[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
// utilizamos test para comprobar si el parametro valor cumple la regla
if(filter.test(valor))
return true;
else
return false;
}

function validar1(form2){
var Password=$("#Password").val();
var Password2=$("#Password2").val();
if(document.form2.Name.value==""){
document.form2.Name.focus();
alert("debes insertar el nombre");
return false;
}else

if(document.form2.Lastname.value==""){
document.form2.Lastname.focus();
alert("debes insertar el apellido");
return false;
}else

if(document.form2.select.value=="Sexo"){
document.form2.select.focus();
alert("debes insertar el sexo");
return false;
}else

if(document.form2.Phone.value==""){
document.form2.Phone.focus();
alert("debes insertar el telefono");
return false;
}else

if(!validar_tel($("#Phone").val())) {
alert("El telefono ingresado no es valido");
document.form2.Phone.focus();
return false;
}else{
if(document.form2.Email.value==""){
document.form2.Email.focus();
alert ("Debes insertar el email");
return false;
}else{
if(!validar_email($("#Email").val()))
{
alert("Email no valido");
document.form2.Email.focus();
return false;
}else{
if(document.form2.Password.value==""){
document.form2.Password.focus();
alert ("Debes insertar el password");
return false;
}else{
if($("#Password").val().length <= 5){
alert ("la longitud del Password debe incluir por lo menos 6 caracteres");
document.form2.Password.focus();
return false;
}else

if(document.form2.Password2.value==""){
document.form2.Password2.focus();
alert ("Debes confirmar el password");
return false;
}
else
if(Password!==Password2){
alert ("la contraseña no coincide");
document.form2.Password2.focus();
return false;
}
else
if(document.form2.recaptcha_response_field.value== ""){
document.form2.recaptcha_response_field.focus();
return false;
}
else
return true;

}
}
}
}
}
</script>
<style>




</style>
<link href="pruebas.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="formulario_registro">
<div id="head_form">
<div id="titulo_form">Registrarse</div>
<div id="close">
<div id="close1"></div>
</div>
</div>
<div id="formulario1">
<form id="form2" name="form2" action="" onsubmit="return validar1()" >
<table width="321" height="385" border="0">
<tr>
<td colspan="3">Nombre:</td>
</tr>
<tr>
<td colspan="3"><label>
<input type="text" name="Name" id="Name" />
</label></td>
</tr>
<tr>
<td colspan="3">Apellido:</td>
</tr>
<tr>
<td colspan="3"><label>
<input type="text" name="Lastname" id="Lastname" />
</label></td>
</tr>
<tr>
<td colspan="3">Sexo:
<select name="select" id="select">
<option>Sexo</option>
<option>Femenino</option>
<option>Masculino</option>
</select>
Telefono:
<input type="text" name="Phone" id="Phone" /></td>
</tr>

<tr>
<td width="63">Email:</td>
<td width="52">&nbsp;</td>
<td width="192"><label></label></td>
</tr>
<tr>
<td colspan="3"><input type="text" name="Email" id="Email" /></td>
</tr>
<tr>
<td>Password:</td>
<td>&nbsp;</td>
<td><label></label></td>
</tr>
<tr>
<td colspan="3"><input type="text" name="Password" id="Password" /></td>
</tr>
<tr>
<td>Confirmar:</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3"><label>
<input type="text" name="Password2" id="Password2" />
</label></td>
</tr>
<tr>
<td colspan="3">Ingresa las dos palabras:
<?php
error_reporting ( E_ERROR );
require_once("../recaptcha/recaptcha/vendors/recaptcha/recaptchalib.php");

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6Leub8USAAAAAFmcx-1Zno2_XTA7AAtzwUVV6NHS";
$privatekey = "6Leub8USAAAAAMPwhgx3moFFje33KzeluarjPdA9";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
}
}
echo recaptcha_get_html($publickey, $error);
?>
</td>
</tr>
<tr>
<td colspan="3">
<div align="right">
<input type="submit" name="boton" id="boton" value="Registrar" />
<br/>
</div></td>
</tr>
</table>
</form>
</div>
<div id="resultado" style="display:none"></div>
</div>
</body>
</html>
------------------------------------------------------------------------------------
  #2 (permalink)  
Antiguo 16/08/2011, 16:57
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 8 meses
Puntos: 1532
Respuesta: problema con recaptcha y javascript

el CAPTCHA solo puede validarse en servidor.

favor utiliza la herramienta highlight del foro.

elimina los datos confidenciales del post
__________________
¡Por favor!: usa el highlight para mostrar código
El que busca, encuentra...

Etiquetas: html, js, php, recaptcha, formulario, botones
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 20:06.