<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <title>TODO supply a title</title>         <meta charset="UTF-8">         <meta name="viewport" content="width=device-width, initial-scale=1.0">     </head>     <body>         <div>             <h1>                 <input type="text" id="hexa" name="hexa" onkeyup="validar_hexadecimal(this)" />             </h1>         </div>         <div id="demo">         </div>     </body>     <script>      function validar_hexadecimal(texto){      var str = texto.value;      var res="";     var valor="";     for(i=0;i<=str.length;i++){         res = str.substring(i, i+1);         if(res=="1" ||res=="2" ||res=="3" ||res=="4" ||res=="5" ||res=="6" || res=="7" || res=="8" ||                 res=="9" ||res=="A" ||res=="a" ||res=="b" ||res=="B" || res=="c" ||res=="C" || res=="d" ||res=="D" ||                 res=="e" ||res=="E" ||res=="f" ||res=="F"){           valor=valor+res;             }     }     document.getElementById("hexa").value = valor;      }        </script>     </html>