Solved

My code for check email, need help.

Posted on 2004-09-06
8
238 Views
Last Modified: 2006-11-17

I have this in my code for the email text box

<asp:RegularExpressionValidator id="valRegEx" runat="server"
    ControlToValidate="email"
    ValidationExpression=".*@.*\..*"
    ErrorMessage="Your entry is not a valid e-mail address."
    display="dynamic">*
</asp:RegularExpressionValidator>


the code does work, but once you click submit it does not stop the page and ignores it anyway, so it is not use telling me then letting me do it anyway!

how to I get it do make sure the user has to enter the correct email address before they can do anything else??

thanks in advance  
0
Comment
Question by:pigmentarts
  • 5
  • 3
8 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 11989814
How do you know that the RegularExpressionValidator works? Does the submit button have CausesValidation property set to true?
0
 
LVL 20

Expert Comment

by:ihenry
ID: 11989835
I always use this validation expression: "http://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" from regular expression editor VS.NET and never have any problem with email validation.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 11989859
i think it works becuase i have other validators on something else that checks for a blank boxes. but on the email one is just the code above, it seems to validate it when the other box has nothing in. but once if i fill in the other box an click submit it just sends it.

i will post my code below so you can see what i mean.




------------------


<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">

      
      
             Sub Submit_Click(Sender as Object, e as EventArgs)
             Dim cnn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("cl.mdb"))
                    Dim cmd As New OleDb.OleDbCommand
               Dim dr As Oledb.OleDbDataReader
 
 
  Session("email") = Nothing
  cmd.Connection = cnn
       cmd.CommandText = "SELECT email, pass FROM members WHERE email = '" & email.Value & "' AND pass = '" & pass.Value & "'"

        cnn.Open()
            
        dr = cmd.ExecuteReader(commandbehavior.closeconnection)
        While dr.read
            Response.Write("Message from load event handler!")
        Session("email") = dr.item("email")
        Session("pass") = dr.item("pass")
        End While
            
            
            
            
If Not (Session("email") = Nothing) Then
      
    Response.Redirect("members.aspx")
      
   Else
   
   Response.Redirect("incorrect.html")
        
End If


     
        cnn.Close()

        cmd.Dispose()
        cnn.Dispose()
 
  end sub
 
 
     </script>

      
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/mainTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="quotes.js"></SCRIPT>

<script>
function quotePrint()
{
var index = parseInt(Math.random()*Quotes.length)

return(Quotes[index])
}

</script>
      <!-- InstanceBeginEditable name="doctitle" -->
      <title>Members Login Page</title>
      <!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <!-- InstanceBeginEditable name="head" -->      <!-- InstanceEndEditable -->
<link href="stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
      font-size: 16px;
      font-weight: bold;
}
.style4 {font-size: 14px}
.style5 {font-size: 14px; font-weight: bold; }
-->
</style>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
      <tr>
            <td style="width: 5%; background: #EEE; border-right: 1px solid #AAA;">&nbsp;</td>
            <td>
            <div class="londonLandscape">
                  <a href="index.html" target="_self"><img src="images/logo.gif" alt="Connecting London Logo" border="0" align="left" style="margin-right: 10px; "></a>
                  <img src="images/londonpic.jpg" alt="Connecting London Logo" align="right">
              <div style="padding-top: 15px; "><br />
                  <span class="textSize style1"><span class="textSize style4">Information – Communications - Technology</span></span><span class="style5"></span><span class="style1"><br />
               </span>              <span class="blueText">We support you...</span></div>
              <span class="blueText">not just your systems!</span></div>
            </div>
            <div id="topmenu1">
                <div style="float:right; "><a href="aboutus.html" target="_self">about us</a> | <a href="contactus.html" target="_self">contact us</a> | <a href="legal.html"> legal</a> | <a href="careers.html" target="_self">careers</a> | <a href="sitemap.html" target="_self">sitemap</a></div>
                         <!-- InstanceBeginEditable name="stat" -->home&gt;member area login<!-- InstanceEndEditable -->
            </div>
            <div style="clear: both; margin-top: 20px;">
                  <div class="box3">
                  <div class="specialOfferBox">
                  <div class="smallTitle" style="color:#FF0000; font-size: 12px;">Special Offer This Month</div>
            </div>
            <div class="graybox">
                  <center><b>
                  <p>EMAIL PROTECTION AGENCY (EPA) SPAM PROTECTION FOR BUSINESS:</p>
                  <p class="FreeTrial"> FREE 15-DAY TRIAL</p>
                  <p>EPA Spam Potection is <br>
                    available to registered <br>
                    Connecting London <br>
                members FREE for 15 days.</p>
                  </b>
                    <p>members click here <a href="membercheck.aspx">click here</a>.
                  <p class="textSize">If you are not a Connecting London member, and would like to apply for membership please register <span class="redlink"><a href="register.aspx">click here
                  </a></span><br>
                  <br>There's no charge for joining, and you do not have to be an existing client.</p>
                  </center>
            </div>
            <div class="smallTitle">Our business partners</div>
                  <div class="graybox" align="center">
                    <img src="images/logos.jpg" alt="logos">
            </div>
      </div>
<div class="box1">
            <div id="nav" style="padding-bottom: 30px; ">
                  <ul class="level1">
                  <li><a href="index.html"><strong>Home</strong></a></li>
                  <li><a href="private_clients .html"><strong>Private Client Computing</strong></a></li>
                  <li class="submenu"><a href="corporate_client_computing.html"><strong>Corporate Client Computing </strong></a>
                   <ul class="level2">
                   <li><a href="corporate_client_consultancy.html">Consultancy</a></li>
                  <li><a href="/">Networks</a></li>
                  <li><a href="/">Computer Services</a></li>
                  <li><a href="communications_services.html">Communications Services </a></li>
                  <li><a href="internet_services.html">Internet Services</a></li>
                  <li><a href="training_and_familiarisation.html">Training</a></li>
                  <li><a href="service_and_maintenance.html">Service and Maintenance</a></li>
                  <li><a href="/">Financing</a></li>
             </ul>
            </li>
            <li><a href="computer_systems_maintenance_service_and_support.html"><strong>Service & Maintenance</strong></a></li>
            <li><a href="case_histories.html"><strong>Case Histories</strong></a></li>
              <li><a href="customer_charter.html"><strong>Customer Charter</strong></a></li>
        </ul>
</div>
<div class="smallTitle" align="right">Members Email Login</div>
      <div class="graybox"><form method="post" action="membercheck.aspx">
      <center>
      
      


      User Name
      <input name="username" type="text">
      Password
      <input name="password" type="password">
      <br>
      <div align="right">
      <input name="Login" type="submit" value="Login">
      
      </div>
      </center></form>
      If you are a registered member and want to access the members area please <a href="membercheck.aspx">click here</a>      </div>
      <div class="smallTitle" align="right">What our clients say about us</div>
      <div class="graybox">
            <script>document.write(quotePrint())</script>
      </div>
</div>
      <div class="box2">
            <!-- InstanceBeginEditable name="content" -->
            <div class="graybar"><img src="images/headings/login.gif" alt="welcome image"></div><br><br>
<form runat="server">
<table width="auto"  border="0" align="left" cellpadding="5" cellspacing="0">
  <tr bgcolor="#DFDFDF">
    <td colspan="3"><b>Login Control:</b></td>
    </tr>
  <tr bgcolor="#F7F7F7">
    <td><div align="right">Email Address: </div></td>
    <td><input type="text" ID="email" value="" runat="server"></td>
      <td>    <div align="left"><asp:RegularExpressionValidator id="valRegEx" runat="server"
    ControlToValidate="email"
    ValidationExpression=".*@.*\..*"
    ErrorMessage="Your entry is not a valid e-mail address."
    display="dynamic">*
</asp:RegularExpressionValidator></td>
  </tr>
  <tr bgcolor="#F7F7F7">
    <td bgcolor="#F7F7F7"><div align="right">Password:</div></td>
    <td><input type="password" ID="pass" value="" runat="server"></td>
      <td><asp:RequiredFieldValidator runat=server
            ControlToValidate=pass
            ErrorMessage=""> * </asp:RequiredFieldValidator></td>
  </tr>
  <tr bgcolor="#F7F7F7">  
    <td>&nbsp;</td>
    <td><input type="submit" OnServerClick="Submit_Click" value="Submit" runat="server"></td>
      <td>&nbsp;</td>
  </tr>
  <tr bgcolor="#F7F7F7">
    <td colspan="3"><p><strong>If you are not a connecting London member <br> then please <a href="register.aspx">register</a> with us for free. </strong></p></td>
    </tr>
</table>



</form>

            <!-- InstanceEndEditable --></div>
</div>
      <div class="box4">
              For more information call:<br>
            <b>Gary Howells on 020 7591 5455 or Robert Saleh on 020 7591 5454<br></b>
             or <a href="mailto:email sales@connectinglondon.com ">email sales@connectinglondon.com </a></div>
      </td>
            <td style="width: 5%; background: #EEE; border-left: 1px solid #AAA;">&nbsp;</td>
      </tr>
</table>
</body>
<!-- InstanceEnd --></html>
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 11989864
is this code right then or do i have it wrong?

<asp:RegularExpressionValidator id="valRegEx" runat="server"
    ControlToValidate="email"
    ValidationExpression=".*@.*\..*"
    ErrorMessage="Your entry is not a valid e-mail address."
    display="dynamic">*
</asp:RegularExpressionValidator>
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 20

Expert Comment

by:ihenry
ID: 11989901
I tried your regex, it does not work. validator passed "33hotmail.tt" as a valid email address.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 11989920
o, well, i tried, not very good as this all yet. do you have some code that would work to me to check email is right? thanks
0
 
LVL 20

Expert Comment

by:ihenry
ID: 11989935
as I have posted in my previous comment, just give it a try. it should works.
0
 
LVL 20

Accepted Solution

by:
ihenry earned 500 total points
ID: 11990155
or try this,

<asp:RegularExpressionValidator
      id="valRegEx"
      runat="server"
      ErrorMessage="Your entry is not a valid e-mail address."
      Display="Dynamic"
      ControlToValidate="TextBox1"
      ValidationExpression="(0\d{1,4}-|\(0\d{1,4}\) ?)?\d{1,4}-\d{4}" />
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now