Guest User

Untitled

a guest
Oct 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Captcha</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <link rel="stylesheet" type="text/css" href="css/estilo.css" />
  6. <script src="https://code.jquery.com/jquery-2.1.4.min.js"> </script>
  7. <script>
  8. var captcha = ["overlooks inquiry.JPG","morning overlooks.JPG","fake captcha.JPG"];
  9. var actual=-1;
  10.  
  11.  
  12. function crear_Captcha(){
  13.  
  14. do{
  15. var azar = Math.floor(Math.random()*3);
  16. }while(actual == azar);
  17.  
  18. actual = azar;
  19.  
  20. var txt1="<img src='img/"+captcha[actual]+"' alt='captcha' /><br/>";
  21. txt1 +=" <input type='text' id='txtcaptcha' value='' placeholder='Write Captcha' >";
  22. txt1 += "<input type='button' id='idcaptcha' value='Comprobar captcha'>";
  23.  
  24. document.getElementById("contenidocaptcha").innerHTML = txt1;
  25. document.getElementById("txtcaptcha").focus();
  26.  
  27. }
  28.  
  29. $(document).ready(eventos);
  30.  
  31.  
  32. function eventos(){
  33.  
  34. $("#idcaptcha").click(comprobar_captcha());
  35.  
  36. function comprobar_captcha(){
  37. alert("entro");
  38. var user = document.getElementById("txtcaptcha").value + ".JPG";
  39. alert("vale :" + captcha[actual]);
  40. if( user != captcha[actual]) {
  41. crear_captcha();
  42. alert("diferente");
  43. }else{
  44. alert("bien");
  45. }
  46.  
  47. }
  48.  
  49. $("#idbtnsend").click(preguntar);
  50.  
  51.  
  52.  
  53. function preguntar(){
  54. var confi = confirm("Enviamos ??" );
  55. return confi;
  56.  
  57. }
  58.  
  59. </script>
  60.  
  61. </head>
  62. <body onload="crear_Captcha();">
  63.  
  64. <form name="formconf" action="hola.html" method="POST" >
  65. <div id="contenidocaptcha">
  66.  
  67. </div>
  68.  
  69. <div id="contenido_formulario">
  70.  
  71. <label for="nombre">NOMBRE: </label><input type="text" name="txtname" id="Idtxtname" value="" required> <br/>
  72.  
  73. <input type="submit" value="Enviar" id="idbtnsend" name="btnsend" >
  74.  
  75.  
  76. </div>
  77. </form>
  78.  
  79. </body>
  80. </html>
Add Comment
Please, Sign In to add comment