I need a textbox in my form for entering email address.But address should be business email.Never allow to enter personal gmail or yahoo address or show warning popup while doing so.How to implement that?Can i use angulars ng-pattern to implement it?
Asked
Active
Viewed 1,004 times
4
akhil viswam
- 496
- 9
- 24
-
http://stackoverflow.com/questions/15371506/block-or-prevent-temporary-email-address-domains – Giri May 04 '16 at 05:04
-
Have you tried anything out?Something we can see? – Satej S May 04 '16 at 05:08
1 Answers
1
You can do something like this. No need for angular pattern.
HTML
<form id="signup" method="post">
<input id="email" type="email" placeholder="Your e-mail." />
</form>
JS
$('#email').blur(function() {
validateEmail($('input').val());
return false;
});
function validateEmail(email) {
var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
if (re.test(email)) {
if (email.indexOf('@yourdomain.com', email.length - '@yourdomain.com'.length) !== -1) {
alert('Valid email.');
} else {
alert('Email must be a yourdomain e-mail address (your.name@yourdomain.com).');
}
} else {
alert('Not a valid e-mail address.');
}
}
Check the fiddle
Community
- 1
- 1
Danish Adeel
- 728
- 4
- 11
- 27