2

I have a TextBox in a Windows application in C#.

I want to validate it so that the user can input only the website address in the proper format.

How can I do this?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Nagendra Kumar
  • 604
  • 2
  • 12
  • 20

2 Answers2

3
System.Uri.IsWellFormedUriString(userInput, System.UriKind.Absolute)

or use a regular expression:

What is the best regular expression to check if a string is a valid url

Community
  • 1
  • 1
Dennis Traub
  • 48,682
  • 7
  • 87
  • 104
0

In web application, go to toolbox, then select validation tools. In validation, choose Regular Expression Validator-is a error messager. In the property of regular expression validator, choose ValidationExpression-then select Internet Url

Siva
  • 541
  • 2
  • 7
  • 14