Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I need to validate textbox so that it can only take website url up-to domain code only.
For e.g. User must insert website url as "http://www.google.com".

If user insert "http://www.codeproject.com/Articles/334310/Understanding-ASP-NET-Validation-Techniques" then it should not allow.

Allowed:-"http://www.google.com"

Not Allowed:-"http://www.codeproject.com/Articles/334310/Understanding-ASP-NET-Validation-Techniques"

Please help.
Posted
Comments
ZurdoDev 11-Sep-15 11:04am    
I'd suggest googling for regex examples. That's what I would do.
Sergey Alexandrovich Kryukov 11-Sep-15 11:59am    
Why? why?!
—SA

1 solution

The Regex solution is way too trivial; I don't think there is a need to discuss it; just learn Regex basics.

One obvious solution is to leave the URL part up to the domain name (or the same with some base sub-directory) not editable. Allow to edit only the text on right of the non-editable part. Isn't that simple?

May I suggest some alternatives? I think the whole idea is bad. For the user, it would be practically unusable. It would be better that you simply display all valid URLs (tree view would be fairly good option), so the user's choice of URL will be reduced to selection of desired node.

Perhaps I would be able to give you better advice if you shared the ultimate goal of you weird, really weird requirement.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900