I am trying to make registration form within which I want to register only with specific domains\' emails. For e.g. I want to register only the emails which are from the com
An email is only going to contain one @ so you could split the input value and take the second part
str = str.split('@').slice(1);
then simply check if that is in your acceptable list
var allowedDomains = [ 'x.com', 'y.com', 'z.com' ];
if ($.inArray(str[0], allowedDomains) !== -1) {
//acceptable
}else{
//not acceptable
}
here is a working example in a jsfiddle: http://jsfiddle.net/UwmYK/2/ just type in the email and click run.
What if you have the input textbox only accept the first part of an email address and then have a select box that only has the email domains you want to allow for the user to select from?