Posted by devolution on September 18, 2007
Hi all,I'm trying to work out a Domain Name validation function for use in a utility I'm writing.
I'm working primarily with UK domains (.co.uk, .org.uk and .me.uk) and the general name rules are as follows:
* Characters allowed: A-Z, 0-9 and hyphens
* No hyphens at start or end of domain
* Domain must be at least 2 characters
Examples of valid domains:
music.co.uk, blah.org.uk, we-3.me.uk
Examples of invalid domains:
x.co.uk, -ssd.org.uk, moneyŁ.me.uk
I'm looking to put together a function to validate a string to see if it is a valid domain name. Plus I wish to know if it is a domain with extension (eg: music.co.uk) or just the 'keyword' (eg: music).
Many thanks for any help!!!
Related articles
Follow Ups