Solved

Regular expression

Posted on 2012-04-07
3
316 Views
Last Modified: 2012-04-07
I need to add validation for email to this file.  I went to the registration form an added the validation statements.  Did I do that that right?  yes or no?  If no, explain how this can be resolve.  I am sorry you  have to take on the teacher role today.  I just want to get this done.
SkywardAviationValidation-EE.zip
0
Comment
Question by:assaultkitty
3 Comments
 
LVL 19

Expert Comment

by:Manoj Patil
ID: 37819853
0
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
ID: 37820541
Well, assuming that your validator is correct, it is doing one thing - checking that email is not blank.

You ought to be checking that proper format such as period (.), @ sign, etc are strictly followed.

So, this simple js will accomplish both.

<script language="javascript" type="text/javascript">
    function validateEmail() {
        if (document.getElementById('email').value == "") {
            alert("Email id can not be blank");
            document.getElementById('email').focus();
            return false;
        }
        var emailPat = /^\w[\w\-\'\.]+\@(\w[\w\-\']*\.)+[a-z]{2,6}$/;
        var emailid = document.getElementById('email').value;
        var matchArray = emailid.match(emailPat);
        if (matchArray == null) {
            alert("Your email address seems incorrect. Please try again.");
            document.getElementById('email').focus();
            return false;
        }
        return true;
      }
  </script>

Open in new window


Then you invoke the js on your submit button as:

 
 <asp:Button id="Registerform" runat = "server" Text="Register" OnClientClick="return validateEmail();" CssClass="noprint"/>

Open in new window

0
 

Author Closing Comment

by:assaultkitty
ID: 37820552
After the headache of trying to transcribe the programs before doing the project, I was able to complete the project with help from experts and their suggestion as they forward great websites that I used to complete the project.  thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel file not created as expected 7 46
Error when loading the database 16 54
Error on Add method 1 37
C# parent child form 5 13
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short film showing how OnPage and Connectwise integration works.

930 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

14 Experts available now in Live!

Get 1:1 Help Now