Código HTML:
//Declare a function for get the value of the amount of the digits // var rando; function envia() { var numero=document.getElementById('num').value; // Random numbers // if (numero == 2){ rando=Math.floor(Math.random()*90)+9; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $('#caja').fadeOut(1000); } else if (numero == 3){ rando=Math.floor(Math.random()*900)+99; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 4){ rando=Math.floor(Math.random()*10000)+999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 5){ rando=Math.floor(Math.random()*100000)+9999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 6){ rando=Math.floor(Math.random()*100000)+99999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 7){ rando=Math.floor(Math.random()*1000000)+999999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 8){ rando=Math.floor(Math.random()*10000000)+9999999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 9){ rando=Math.floor(Math.random()*100000000)+99999999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 10){ rando=Math.floor(Math.random()*1000000000)+999999999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 11){ rando=Math.floor(Math.random()*10000000000)+9999999999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } else if (numero == 12){ rando=Math.floor(Math.random()*100000000000)+999999999999; rando=Number(rando); var caja=document.getElementById('caja').innerHTML=rando; $(function(){ $('#caja').fadeOut(1000); }); } } /*=============Compare the Values============*/ function comp() { var caja=document.getElementById('caja').value; var k=document.getElementById('k').value; k=Number('k'); caja=Number('caja'); if (k == rando){ alert("You have a very good memory"); }else{ alert("I'm sorry Try angein"); } } /*=============Show the Numbers============*/ function mostrar(){ $(function(){ $('#caja').fadeIn('slow'); }); }