netflix

mail@pastecode.io avatar
unknown
javascript
2 months ago
1.9 kB
3
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript Form Handling</title>
</head>
<body>
    <form id="myForm">
        <label for="email">Email address:</label><br>
        <input type="email" id="email" name="email" required><br>
        <input type="submit" value="Get Started">
    </form>

    <script>
        const form = document.getElementById('myForm');

        form.addEventListener('submit', (event) => {
            event.preventDefault();

            const emailInput = document.getElementById('email');
            const emailValue = emailInput.value;

            console.log(`Email address: ${emailValue}`);
        });
    </script>
</body>
</html>
This code creates a simple form with an email input and a submit button. The JavaScript code listens for the form submission event, prevents the page from refreshing, retrieves the email input value, and logs it to the console. This is a basic example, and you can further customize it to fit your specific needs.

Is this conversation helpful so far?



<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>JavaScript Form Handling</title> </head> <body> <form id="myForm"> <label for="email">Email address:</label><br> <input type="email" id="email" name="email" required><br> <input type="submit" value="Get Started"> </form>
Edit
Download
Copy code
<script>
    const form = document.getElementById('myForm');

    form.addEventListener('submit', (event) => {
        event.preventDefault();

        const emailInput = document.getElementById('email');
        const emailValue = emailInput.value;

        console.log(`Email address: ${emailValue}`);
    });
</script>
Leave a Comment