Solved

Regular expression

Posted on 2012-04-07
3
305 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
Comment Utility
0
 
LVL 28

Accepted Solution

by:
sammySeltzer earned 500 total points
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

9 Experts available now in Live!

Get 1:1 Help Now