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

223
Vistas
So my problem is to show username and password in alert box after typing in the form text fields .But I am not able to get alert box itself

I need to display both the username and password in alert box after submitting . I tried all the ways but still not getting.I think something is wrong with the button itself.So please let me know what corrections needs to be done.

<html>
<head>
<title>LOGIN </title>  
<script type="text/javascript"> 
function log(user,pass){
var user=document.getElementById(user).value;
var pass=document.getElementById(pass).value;
alert("username:"+user+"passw`enter code here`ord:"+pass);  

}
</script>

</head>

<body>
//taking username and password in text field
<form>  
Username=<input type="text" id=user placeholder="Enter your username"/></br>  
Password=<input type="text" id=pass placeholder="Enter your password"/> </br> 
<input type="button" id=login value="login" onclick = "log(user,pass)"/>   
</form>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You just missed a quote while passing the arguments to the function.

It should be

log('user', 'pass')

(Arguments should be passed as string)

<html>

<head>
  <title>LOGIN </title>
  <script type="text/javascript">
    function log(user, pass) {
      var user = document.getElementById(user).value;
      var pass = document.getElementById(pass).value;
      alert("username:" + user + " password:" + pass);

    }
  </script>
</head>

<body>
  <form>
    Username=<input type="text" id="user" placeholder="Enter your username" /></br>
    Password=<input type="text" id="pass" placeholder="Enter your password" /> </br>
    <input type="button" id="login" value="login" onclick="log('user', 'pass')" />
  </form>
</body>

</html>

about 4 years ago · Juan Pablo Isaza 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