Solved

Regular expression

Posted on 2012-04-07
3
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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