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

304
Visualizações
replace the form with a message -not with PHP

I have this code

<!DOCTYPE html>
<html>
<body>

<p>This example demonstrates how to assign an "onsubmit" event to a form element.</p>

<p>When you submit the form, a function is triggered which alerts some text.</p>

<form action="/action_page.php" onsubmit="myFunction()">
  Enter name: <input type="text" name="fname">
  <input type="submit" value="Submit">
</form>

<script>
function myFunction() {
  alert("the message has been send");
}
</script>

</body>
</html>

I want not to do this alert message.I want to replace the form giving it this message the message has been send

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Put the form in a div, and assign the innerHTML of the DIV to replace the form.

Also, you need to return false; in the onsubmit code to prevent the form from submitting to the server.

function myFunction() {
  document.getElementById("formdiv").innerHTML = "This form has been submitted";
}
<!DOCTYPE html>
<html>
<body>

<p>This example demonstrates how to assign an "onsubmit" event to a form element.</p>

<p>When you submit the form, a function is triggered which displays some text.</p>

<div id="formdiv">
<form action="/action_page.php" onsubmit="myFunction()">
  Enter name: <input type="text" name="fname">
  <input type="submit" value="Submit">
</form>
</div>

</body>
</html>

about 4 years ago · Santiago Gelvez 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