Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!