Validate Email is from Specific Domain

We have a php form that collects some basic information ...

- email
- firstname
- lastname
- company

This signup form is specific to one client so we want to block everyone else from signing up.

Examples of correct email addresses ...

Any address that does not use '' is incorrect and should throw up an error ...

"sorry - that email is not valid"

We want the check to be made before form submission - so, after the user enters their email address and tabs to the next field.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
//Add following javascript validation
        var str= document.form1.emailfield.value;
        var a2 = str.toLowerCase();
        if(a2.indexOf("") == -1)
              alert("sorry - that email is not valid");
<input type='text' name='email' id='email' onchange='validateEmail(this)'>

function validateEmail(Sender){
  var validSuffix = "";
  var emailSuffix = Sender.value.substring(Sender.value.indexOf("@")+1);

  if(validSuffix != emailSuffix){
      alert("sorry - that email is not valid");
      Sender.value = "";
poldingsAuthor Commented:
That works great. Just one thing to make it a bit more user friendly pls ...

How can I adapt it so the focus is back on the 'email' field after the alert has closed?
Yes, I see. There is a problem with Sender.focus(); Replace it with: window.setTimeout(function(){Sender.focus();},10);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
poldingsAuthor Commented:
Perfect. Works a treat.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.