473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

subdomain validation

29
How to validate "subdomain" in atextfiled in coldfusion?
Feb 13 '09 #1

✓ answered by acoder

There are a number of ways, e.g.
Expand|Select|Wrap|Line Numbers
  1. ^\w+(\-?\w)*\w+$
Note: \w is an escape sequence for alphanumeric characters. You could also use [:alnum:] (a character class).

14 5154
acoder
16,027 Expert Mod 8TB
What do you mean by a subdomain? Can you explain with an example. Some code might also help.
Feb 13 '09 #2
CFFAN
29
these are rules to create Sub-Domain Names
Sub-Domain Names

A Sub-Domain Name does not form part of a Registered Domain Name, therefore the rules laid down by the Registrar do not apply.

The characters you can choose from:

* A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
* 1 2 3 4 5 6 7 8 9 0
* Hyphen (-)
* An address must begin and end with an alphanumeric character. Punctuation characters must not be placed together
* Sub-Domain names can contain letters, numbers or hyphens (-), NO spaces or other characters are allowed.
me have lot fdoubts in tht...is more than 2 Hyphen possible? etc..i have to validate thesein coldfusion
Feb 13 '09 #3
acoder
16,027 Expert Mod 8TB
You can use a regular expression to make the checks in one go. See this link.
Feb 13 '09 #4
CFFAN
29
K thanks

<cfset result = REMatch("/^[a-zA-Z0-9\-]*?$/",arguments.subdomain)>



i used this code for checking subdomain validation. but always getting empty array....hw can i?
Feb 16 '09 #5
acoder
16,027 Expert Mod 8TB
Why do you have a ? in there? Can you give an example of input (arguments.subdomain)?
Feb 16 '09 #6
CFFAN
29
arguments.subdomain is test123
Feb 16 '09 #7
acoder
16,027 Expert Mod 8TB
The regular expression will not match all the conditions that you specified in an earlier post. For a start, try using a +, e.g.
Expand|Select|Wrap|Line Numbers
  1. ^[a-z0-9\-]+$
Note that REMatch is case-insensitive so there's no need to specify different cases.
Feb 16 '09 #8
CFFAN
29
ok thanks ..
i have to satisy there two condition also
*An address must begin and end with an alphanumeric character. Punctuation characters must not be placed together
* Sub-Domain names can contain letters, numbers or hyphens (-), NO spaces or other characters are allowed.
how can this also possible with ?
Feb 16 '09 #9
acoder
16,027 Expert Mod 8TB
The second condition is already satisfied. For the first condition, you can add a alphanumeric pattern at the beginning and the end:
Expand|Select|Wrap|Line Numbers
  1. /^[a-z0-9][a-z0-9\-]+[a-z0-9]$/
You'll need to add a bit more to ensure that the hyphen doesn't appear more than once together.
Feb 16 '09 #10
CFFAN
29
<cfscript>
result = REMatch("/^[a-z0-9][a-z0-9\-]+[a-z0-9]$/",arguments.Webaddress);
</cfscript>

<cfdump var="#result #"> always getting empty array..
i test with test,test12t etc ....stil sme probs
Feb 16 '09 #11
CFFAN
29
i remove staring / and eng /.then it works....

<cfscript>


result = REMatch("^[a-z0-9][a-z0-9\-]+[a-z0-9]$",arguments.Webaddress);
</cfscript>


how to avoid continous repetaion of hyphn?
Feb 16 '09 #12
acoder
16,027 Expert Mod 8TB
There are a number of ways, e.g.
Expand|Select|Wrap|Line Numbers
  1. ^\w+(\-?\w)*\w+$
Note: \w is an escape sequence for alphanumeric characters. You could also use [:alnum:] (a character class).
Feb 16 '09 #13
CFFAN
29
Now it workg fine...ok thank u very muchhhh
Feb 16 '09 #14
acoder
16,027 Expert Mod 8TB
You're welcome. Glad it's working :)
Feb 16 '09 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Leon | last post by:
How do I point a sub-domain to a sub-directory or .aspx page of my site using asp.net? I'm using a shared hosting service, that does not offer subdoman forwarding. however, you can write your...
2
by: Bill Borg | last post by:
Hello, I have a couple web services that I use across my apps. My isp supports exposing them either via subdomain (e.g. services.mydomain.com) or subfolder (e.g. mydomain.com/services). Are...
1
by: perspolis | last post by:
Hi If I want to create subdomain for my site dynamicaly how can I do that with ASP.NET? or is it possib;e to create subdomain with IIS?? thanks
1
by: thomas | last post by:
Hello all, It seems like subdomain forwarding prevents ASP.Net session state from working correctly. Example: two websites http://www.jgphotographers.com/test and...
0
by: Greg | last post by:
Is it possible for authentication using asp.net membership to persist from a site to a subdomain? The scenario I want to provide is: User browses to the page somesite.com and logs in. User...
12
by: Tina | last post by:
Our company domain, say, wombat.com needs to create several subdomains: support, training, and purchase are three of the subdomains needed. So when someone browses to //training.wombat.com they...
3
by: a2rodger | last post by:
I am using the following function and parse_url() to attempt to grab the subdomain from my sites url function selfURL() { $s = empty($_SERVER) ? '' : ($_SERVER == "on") ? "s" : ""; $protocol =...
0
by: devilsjunk | last post by:
Hello Everybody, In my web application I have created an interface where, if any user register then a subdomain will be created with the user name of the user link this manner E.G. :-...
1
by: Josh | last post by:
I have a question about subdomains. I would like my website to have subdomains that essentially show my regular main website, except that the subdomain passes as a variable on all pages so that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.