Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vallidate a user typed link 1

Status
Not open for further replies.

Premalm

Programmer
Mar 20, 2002
164
US
Hi Guys,

I was wondering if there is any way to validate a user typeed link.
The user is going to type or copy the link in a text box.
Is there any way to validate this link through some code ?

Thanks
Pr
 
validate for what? check if it's a valid url or what?

you may want to look into the custom validator control.

 
I need to provide a text box to the user. The user is going to either type a link in the text box or copy a link and this is going to be saved in the database.

This is the reason why I need to validate the link in the text box.

Thanks
Pr
 
I understand what your saying.. but validate it for what? what do you want to check?

do you just want to check to make sure it's valid syntax or what? if so, you may be able to use the custom validator.


 
Even for using custom validator the validation code has to be written by me. I am talking about the validation code.

for e.g. If the user has typed this link wrong in the text box I can show a message box.

Thanks
Pr
 
So when you say you want to validate a link, you actually mean you want to check if the string is in the correct form for a URL?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
OK, you'll probably want to use a Regular Expression. Try looking here for some examples:


Also, remember just because the text is in a valid format, it doesn't mean that the website exists.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
that's what I meant by saying valid syntax.



>>for e.g. If the user has typed this link wrong in the text box I can show a message box.

are you going to provide valids url's to validate against? if not you will have to write that in code unless there is some third party app that will do that for you..
 
sorry, I didn't know the regular expersion validator did that...I learned something as well.
I thought that was just for postal etc..

 
Yeah, Regular Expressions can be used to match pretty much any scenario you want (or can write as they can get stupidly complicated!).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi,
Just an added note..The URL can be valid but totally incorrect - you may want to find some way of testing its 'correctness' - that is , can you go to that entered link?..

May not be important, but just thought a reminder about user error would be helpful..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
No we are not getting into testing the correctness of the URL. We will have to trust the user. We do not want to complicate it.

But thanks for bringing this point up Turkbear.

Thanks
Pr.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top