Click here to Skip to main content
12,997,038 members (128,987 online)
Rate this:
Please Sign up or sign in to vote.
I have an email textbox (required field) and a button. I want that whenever a user puts his mail id and clicks the button a JavaScript popup should appear.

My problem is when I click the button, that popup is appearing before the required-field msg.

I want JavaScript code written in a way that if textbox is empty then it will show a "please enter email id" validation message and if user gives his email id then that popup will appear; otherwise not.

pls help me out

this is my text box and button

<div class="input-append">
              <input type="email" id="email" name="email" placeholder="Your Email" required>
              <button class="subscribe-button btn" type="submit" onclick="myFunction()">SUBSCRIBE</button>

and this is my javascript code

<script type="text/javascript">
function myFunction() {
    alert("You have done it");
Posted 28-Aug-14 20:59pm
Updated 29-Aug-14 5:15am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Gihan Liyanage 15-Sep-14 6:21am
Did you got a solution from my support, I can see you have not accepted any answer.If you are ok with this answer plz accept it. Then any user having same problem can identified it has solved the problem..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 29 Aug 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100