Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <script> function confirmInput() { fname = document.forms[0].fname.value; alert("Hello " + fname + "! You will now be redirected to www.w3Schools.com"); } </script> </head> <body> <h1>JavaScript HTML Events</h1> <h2>The onsubmit Attribute</h2> <form onsubmit="confirmInput()" action="https://www.w3schools.com/"> Enter your name: <input id="fname" type="text" size="20"> <input type="submit"> </form> </body> </html>