jQuery Domain Name Validation

jquery_logo

function validateEmail(email) {
document.getElementById(“vsubmit”).removeAttribute(‘disabled’,’disabled’);
var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
if (re.test(email)) {
if (email.indexOf(‘@xyz.in’, email.length – ‘@xyz.in’.length) !== -1) {

} else {
document.getElementById(“vsubmit”).setAttribute(‘disabled’,’disabled’);
alert(‘Email must be xyz.in domain (name.title@technokrats.in).’);
}
} else {
alert(‘Not a valid e-mail address.’);
}
}

HTML

<input type=”email” onblur=”validateEmail(this.value)” name=”email” value=”” placeholder=”email” required>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: