?
Solved

Regular expression

Posted on 2012-04-07
3
Medium Priority
?
349 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 29

Accepted Solution

by:
sammySeltzer earned 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

762 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