Please visit my new Web Site https://coderstechzone.com
Email address validation is a most common scenario for a developer. It will be the best if we can use javascript validation along with server side validation since user may off javascript from browser settings. The following example shows how you can validate an email address for a form. The script is cross browser compatible (works for all browsers such as IE, Firefox, Opera).
Javascript email validation using regular expression:
Here i tried to find out a simple solution to prhibit users to enter wrong email address. There is a lot of scope here to modify the regular expression. To do that you have to learn regular expression syntax. Now add the below function within your head tag or within the content tag for child page.
Javascript email validation using regular expression:
Here i tried to find out a simple solution to prhibit users to enter wrong email address. There is a lot of scope here to modify the regular expression. To do that you have to learn regular expression syntax. Now add the below function within your head tag or within the content tag for child page.
So simple. Ok now we want to modify a little bit for better look & feel.
Now i am showing how we use the above javascript email validation function in our aspx page.
Simple output:
Asp.net C# email address validation:
I have already explained why we need to write server side validation. Now i want to show you an example how we can validate email address:
For code reusability it will be best to add a static class in our project for such type of validation. Here i am adding a static class named validation.cs:
Now from our aspx page write the below code when user click on a button to proceed.
Hope now readrers can easily implement the both javascript & server side validation & also can modify.
3 comments:
hi shwapnendu,
I m working on similar lines, but i wanted to know if u cud help me in checking if an email id exists or not !!!
The expression is correct but say if - username@gmail.com account exists or not
Hi PRATS,
You will get a lot of free web service but i am little bit confused because continuous checking of google, yahoo, msn id may be your IP will be black listed. Thats why if you look at the famous sites they activate the user account by sending a mail with an activation link.
So i think it will be better if you want to keep your contacts clean follow the above technique.
If you need badly then you can try with VRFY(most mail server admin disables this feature for spammers) function of SMTP. For more details read rfc of SMTP.
hi thank u alot it helps me alot
I WOULD BE DELIGHTED TO HEAR FROM YOU