Solved

Regular expression

Posted on 2012-04-07
3
325 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 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