email validation

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Alidad
Forum Commoner
Posts: 29
Joined: Thu Mar 29, 2007 12:42 pm

email validation

Post by Alidad »

Hi, I need help with registration forms. There are two text fields for (email and business website url address).

when person sign up and put website url address, and the email extension address should be match with the website extension address.

For sample that company website name www.amazon.com, and employee email should "xxxx@amazon.com".

How can i write the validation code to prevent continue process if website extension address are not same as email extension address!

pleae help thanks.

AM
mike_ebrahimi123
Forum Newbie
Posts: 3
Joined: Mon Mar 14, 2011 3:57 pm

Re: email validation

Post by mike_ebrahimi123 »

function validate(form_id,email) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;
if(reg.test(address) == false) {
alert('Invalid Email Address');
return false;
}
}
Post Reply