I would like to create a web page that has a contact form. Use only HTML, CSS, and JS to…
- User
I would like to create a web page that has a contact form. Use only HTML, CSS, and JS to produce one.
Assistant
Here's an example of a simple contact form built with HTML, CSS, and JavaScript:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contact Form</title> <style> body { font-family: Arial, sans-serif; } form { display: flex; flex-direction: column; width: 300px; margin: 0 auto; } label, input, textarea { margin-bottom: 5px; } </style> </head> <body> <h1>Contact Form</h1> <form id="contact-form"> <label for="name">Name:</label> <input type="text" id="name" name="name" required> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <label for="message">Message:</label> <textarea id="message" name="message" required></textarea> <input type="submit" value="Submit"> </form> <script> document.getElementById("contact-form").addEventListener("submit", function(event) { event.preventDefault(); var name = document.getElementById("name").value; var email = document.getElementById("email").value; var message = document.getElementById("message").value; alert("Name: " + name + "\nEmail: " + email + "\nMessage: " + message); }); </script> </body> </html>This code creates a simple contact form with fields for the user's name, email, and message. When the user submits the form, the JavaScript code prevents the default form submission behavior and collects the values of the fields. It then displays an alert with the collected information.
To use this code, simply copy and paste it into a new HTML file and open the file in your
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.