Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
XML
<script type="text/javascript">
    var Email = document.getElementById('<%=txtemailid.ClientID %>').value;
    function empty()
    {
    if(Email=="")
    {
    alert("Your email address seems incorrect. Please try again.");
       return false;
    }
    }
 </script>


ASP.NET
<asp:Button ID="submit" runat="server" Text="Submit" OnClientClick="return empty();" onclick="submit_Click" />


[Edit]Code block added[/Edit]
Posted
Updated 27-Oct-12 2:07am
v2
Comments
OriginalGriff 27-Oct-12 7:42am    
So what is happening that shouldn't, or isn't happening that should?
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Umapathi K 27-Oct-12 7:54am    
nothing happend. jus form getting load thats it
DaveAuld 27-Oct-12 8:09am    
What Griff means is, what are you expecting to happen, what are you trying to do that makes you think something is not working! Expand on the details please.
Umapathi K 27-Oct-12 8:12am    
when user hits submit button with out enter anything in the 'txtemailid' textbox alerts should throw
Sandeep Mewara 27-Oct-12 11:39am    
So you say, you are not getting the 'alert' message?

Read the following on how to use the getElementById function :http://www.tizag.com/javascriptT/javascript-getelementbyid.php[^]
 
Share this answer
 
Hi Umapathi K,

just copy and paste the below code and it will work.
JavaScript
<script type="text/javascript">
   
    function empty()
    {
 var Email = document.getElementById('<%=txtemailid.ClientID %>').value;
    if(Email=="")
    {
    alert("Your email address seems incorrect. Please try again.");
       return false;
    }
    }
 </script>
 
Share this answer
 
v3

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