html - Allow only specific email address' domain to register through JQuery (preferably) -


i trying make registration form within want register specific domains' emails. e.g. want register emails companyx, companyy, companyz.

hence acceptable emails be:-

  • myname@companyz.com
  • myname@companyy.com
  • myname@companyx.com

any idea how in jquery?

update

this wrote, uptill now

($input)  if (      (preg_match("/^\s+@companyx\.com$/i", $input) ||      (preg_match("/^\s+@companyy\.com$/i", $input) ||      (preg_match("/^\s+@companyz\.com$/i", $input)    ) {  } else {       //error. } 

thanks

an email going contain 1 @ split input value , take second part

str = str.split('@').slice(1); 

then check if in acceptable list

var alloweddomains = [ 'x.com', 'y.com', 'z.com' ];  if ($.inarray(str[0], alloweddomains) !== -1) {     //acceptable }else{     //not acceptable } 

here working example in jsfiddle: http://jsfiddle.net/uwmyk/2/ type in email , click run.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -