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,738
  • 21
  • 105
  • 131
Nagendra Kumar
  • 634
  • 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
  • 50,557
  • 7
  • 93
  • 108
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
  • 561
  • 3
  • 7
  • 14