Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML jQuery
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>
            </div>
 
and this is my javascript code
 
<script type="text/javascript">
function myFunction() {
    alert("You have done it");
}
</script>
Posted 28-Aug-14 21:59pm
Edited 29-Aug-14 6:15am
v2

1 solution

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

Solution 1

  Permalink  
Comments
Gihan Liyanage at 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
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,382


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 29 Aug 2014
Copyright © CodeProject, 1999-2014
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