Click here to Skip to main content
15,898,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello sir,

I am doing project in C#.NET The project title is "Estimation of defects based on Defect decay model".I got login as a module but if he is new then he has to register in registration form.In the form i have taken the fielda as username,password,conformpassword and Email-id.

my problem is
All the fields should be validated compulsorly and FOR Email-id compulsorly . and @ symbols are to be given by user then only if user clicks on submit it has to enter database.

plz solve my problem.
Posted

You can do it using Regular expressions.

C#
using System.Text; 

private bool IsValidEmail(string email)        
{            
    string emailRegEx = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|"
                      + @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*([-][a-z|0-9]+)*\.([a-z]" 
                      + @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";
    RegularExpressions.Match match = 
    RegularExpressions.Regex.Match(email, emailRegEx, RegularExpressions.RegexOptions.IgnoreCase);            
    return match.Success;  
}


Read this for more info:
MSDN: How To: Use Regular Expressions to Constrain Input in ASP.NET[^]
 
Share this answer
 
Use Regular Expression validator and find out the regular expression on google :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900