0

Hello,

I am trying to write email confirmation with javascript:

     <div class="step">
                <h4>Enter your email address:</h4>

                    <div class="container">
                        <input type="text" name="email" value="Enter your email here" title="Enter your email here" class="field" />
                    </div>
                    <h5>Step 2 of 2</h5>
                    <span class="progress"><span style="width: 100%">&nbsp;</span></span>
                    <input class="email-btn button" type="submit" value="Send" />
                </form>
            </div>

            ...

            $('.email').click(function() {

    var email = $(this).parent().find('email').val();

    if (email == null) {
        alert('Please enter your email address.');
    }

    return false;
};

How to write the javascript?

2
Contributors
2
Replies
14
Views
1 Week
Discussion Span
Last Post by davy_yg
0

You have a trigger for clicking on a tag with class of 'email'. But this class does not exist in your markup.

0

I change the codes to:

 <div class="step">
                <h4>Enter your email address:</h4>

                    <div class="container">
                        <input type="text" id="email" name="email" value="Enter your email here" title="Enter your email here" class="field" required/>
                    </div>
                    <h5>Step 2 of 2</h5>
                    <span class="progress"><span style="width: 100%">&nbsp;</span></span>
                    <input class="email-btn button" type="submit" value="Send" />
                </form>
            </div>

 ...

 <script>

 $('.email-btn').click(function() {

    var email = $("#email").val();

    if (email == ''){
        alert('Please enter your email');
    }

    return false;
});

</script>

I wonder why it still pass the page without any alert evenif it's empty?

Edited by davy_yg

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.