This may be a little off topic, but after searching the Internet for several hours and testing various RegExp (which will work for me). I decided to write my own function, which would take a list of valid TLD extensions and check against them. So for those who have a similar problem, check out my Javascript function:
function domainCheck(dom) { // convert input to lowercase. dom = dom.toLowerCase(); // find the first occurance of '.' pos = dom.indexOf("."); // Using the first occurance of '.' // find the extension submitted. tld = dom.substring(pos); switch(tld) { // TLD to accept. case '.com': return true; break; case '.co.uk': return true; break; case '.eu': return true; break; case '.io': return true; break; case '.co': return true; break; case '.net': return true; break; default: return false; } }
I created a demo using this function here: http://jsfiddle.net/netfox/MhPG8/19/embedded/result/
source share