Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

229
Vistas
why doesn't html file connect with javascript file?

I have a problem guys. Trying to write HTML and JS code in different files and connect them. I think I have done it, but nothing works. How it must be done? (javascript file name is correct)

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="index.js">
    <title>Document</title>
</head>

<body>
    <h3>Check password size</h3>
   <div class="checker">
     <input type="password" name="passcode" placeholder="Enter password" ><br><br>
     <input type="submit" value="check my password!" onclick="checkpassword()">
   </div>
<p id="message" class="message"></p>
</body>
</html>

JAVASCRIPT

function checkpassword(){
    var pas=document.getElementsByName('passcode')[0].value;
    var x=pas.length;
    document.getElementById("message").innerHTML="Password size is" +" " +x +" " +"characters";
}
about 4 years ago · Santiago Gelvez
3 Respuestas
Responde la pregunta

0

You sould use the following line to call for/import your javascript.

<script type="text/javascript" src="index.js"></script>

The way you are writing the code is only to call for a css file. To call for a different language, you use a different code.

about 4 years ago · Santiago Gelvez Denunciar

0

<script src="fileName.js"></script>

This is used to connect js to html src means source One more way to do js in html is by using in html and writing your code in the tag like

<script>
function checkpassword(){
var pas=document.getElementsByName('passcode')[0].value;
var x=pas.length;
document.getElementById("message").innerHTML="Password size is" +" " 
+x +" " +"characters";
}
</script>

you can put this code in html or can make seprate files

hope it helped you :)

about 4 years ago · Santiago Gelvez Denunciar

0

You need to use the script tag to connect javascript with html

<script src="yourFile.js"></script>
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda