Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Captcha</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="stylesheet" type="text/css" href="css/estilo.css" />
- <script src="https://code.jquery.com/jquery-2.1.4.min.js"> </script>
- <script>
- var captcha = ["overlooks inquiry.JPG","morning overlooks.JPG","fake captcha.JPG"];
- var actual=-1;
- function crear_Captcha(){
- do{
- var azar = Math.floor(Math.random()*3);
- }while(actual == azar);
- actual = azar;
- var txt1="<img src='img/"+captcha[actual]+"' alt='captcha' /><br/>";
- txt1 +=" <input type='text' id='txtcaptcha' value='' placeholder='Write Captcha' >";
- txt1 += "<input type='button' id='idcaptcha' value='Comprobar captcha'>";
- document.getElementById("contenidocaptcha").innerHTML = txt1;
- document.getElementById("txtcaptcha").focus();
- }
- $(document).ready(eventos);
- function eventos(){
- $("#idcaptcha").click(comprobar_captcha());
- function comprobar_captcha(){
- alert("entro");
- var user = document.getElementById("txtcaptcha").value + ".JPG";
- alert("vale :" + captcha[actual]);
- if( user != captcha[actual]) {
- crear_captcha();
- alert("diferente");
- }else{
- alert("bien");
- }
- }
- $("#idbtnsend").click(preguntar);
- function preguntar(){
- var confi = confirm("Enviamos ??" );
- return confi;
- }
- </script>
- </head>
- <body onload="crear_Captcha();">
- <form name="formconf" action="hola.html" method="POST" >
- <div id="contenidocaptcha">
- </div>
- <div id="contenido_formulario">
- <label for="nombre">NOMBRE: </label><input type="text" name="txtname" id="Idtxtname" value="" required> <br/>
- <input type="submit" value="Enviar" id="idbtnsend" name="btnsend" >
- </div>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment