Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda