Community forum for knowledge and support

Updated 10 months ago

Reveal Additional Fields on Valid Email Input

At a glance

<script>
$(document).ready(function() {
    // Hide the additional fields initially
    $('.additional-fields').hide();
    
    // When the user types in the email input
    $('#email-input').on('input', function() {
        var email = $(this).val();
        // You can add your email validation logic here
        
        // If email is valid, reveal the additional fields
        if (isValidEmail(email)) {
            $('.additional-fields').slideDown();
        }
    });
    
    // Function to validate email (you can replace this with your own validation logic)
    function isValidEmail(email) {
        // Your validation logic here
        return /\S+@\S+\.\S+/.test(email);
    }
});
</script>

M
H
6 comments

do you have jquery included in the project already somewhere or? Because this code here looks like JQuery to me.

I would highly recommend Slater.app - https://slater.app/ - this is a perfect use case for it.

I barely know JS but I used it to create a calculator form hooked up to a mapbox API to calculate delivery estimates.

hey matt, I havent got any jquery anywhere else on the site. Im no js expert either haha. Thanks mate will take a look at slater!

okay, I would prompt GPT to not use JQuery then, and see if what it results in might work. I really dont think you "need" JQuery.

Also I assume this is a Webflow project, and I do think that JQuery is baked into Webflow but I don't know that 100%.

Safer to just try to get the interaction working with vanilla JS first, then slowly add in complexities like animations/transitions etc.

Sorry should of been more specific, yeah this is a webflow project!

let me go talk to chatgpt and see what it says

Add a reply
Sign up and join the conversation on Slack