Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

XML
<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

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

1 solution

 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900