Suppose that I have a login page where users need to enter their email addresses. The email addresses will only have a .edu domain name extension.

I was wondering if there was a way for me to figure out what college the user went to based on his/her email address? I know the manual way is to simply copy/paste the ending of their email address. For example: - I would manually type the 'mit.edu' into the URL address bar and figure out what school it is.

However, this is very arduous, and there are 2000 colleges in the USA. I'm more interested in a user experience like this:
EMAIL:

user types in ""

COLLEGE: populates automatically with: Eastern Mississippi State College

Dani AI

Generated

Short answer: yes — extract the hostname from the user’s email client-side, then look it up server-side in a maintained domain→institution table (fast UX) that you populate from an authoritative dataset. That combines the quick feedback and suggested (split/trim on the client) with ’s regex idea, and avoids manual copy/paste forever. EDUCAUSE is the official .edu registrar (useful for WHOIS/validation). (educause.edu)

Client-side: extract and normalise the part after the “@” (handle subdomains), show a spinner, then call your API. Use a small, defensive routine rather than a single fragile regex — subdomains like dept.university.edu should map to university.edu before lookup. Example:

function canonicalEduDomain(email){
  const host = (email.split('@')[1] || '').toLowerCase().replace(/[:\/].*$/,'').trim();
  if(!host) return '';
  const parts = host.split('.');
  // simple rule: for .edu use last two labels (dept.univ.edu -> univ.edu)
  if(parts.length >= 2 && parts[parts.length-1] === 'edu')
    return parts.slice(-2).join('.');
  return host;
}

// then async lookup:
fetch('/api/college?domain='+encodeURIComponent(canonicalEduDomain(value)))
  .then(r=>r.json()).then(j=> fillCollegeField(j.name));

Server-side: keep a JSON or DB keyed by canonical domain. Build that mapping from reliable sources (U.S. institutions: College Scorecard’s school records include official URLs; for broader/global coverage use a maintained university-domains list on GitHub). Parse school.school_url to extract hosts and dedupe aliases into one institution record. (collegescorecard.ed.gov)

Caveats / UX details: some institutions have multiple domains or use department subdomains, some older/nonstandard .edu names are grandfathered, and many users will sign in with non-.edu emails or forwarded accounts — so always offer a small autocomplete + “Not your school?” fallback. For ambiguous matches or misses, log them for manual review and update the domain table; EDUCAUSE’s WHOIS/FAQ is the authoritative source for .edu registration rules. (net.educause.edu)

Recommended Answers

All 4 Replies

What you're looking at is a good bit of JavaScript work. You'll need to trim the string from the '@' part, and put the rest, to rest. I really don't know how you are going to find the name of the college exactly, though you can always create a database and then refer towards it using a server-side language/script. You might find the trim() function in JS pretty useful. This forum is not for this post, though :P

Try posting in the JavaScript or PHP forum. AJAX is your friend here, too. Plus, I recommend w3schools.com

,

I'm looking into w3schools right now.

What you're looking at is a good bit of JavaScript work. You'll need to trim the string from the '@' part, and put the rest, to rest. I really don't know how you are going to find the name of the college exactly, though you can always create a database and then refer towards it using a server-side language/script. You might find the trim() function in JS pretty useful. This forum is not for this post, though :P

Try posting in the JavaScript or PHP forum. AJAX is your friend here, too. Plus, I recommend w3schools.com

I would just like to point out that,

Since JavaScript doesn't include a trim method natively,[..]

here is a little research towards finding the most efficient approach to implementing it in a library.

http://blog.stevenlevithan.com/archives/faster-trim-javascript

but he won't need to trim, he will need to split ;)

and yes the database is probably the best route to go for this, unless there is some kind of governement site that offers a webservice you could use to querry the answer from their constantly updated database. Otherwise, its all about your database with your responsability to update it, even if colleges probably don't close or open everyday it will still need updating eventualy!

regex.

you should be able to write a regex function taking everything between
@ and .edu

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.