0

I am working on using a validation expression to authenticate valid youtube urls. What I have does the job well except in IE it comes up as required when I need it as optional.

I did some research and tried an alternate method but it still come sup as required in IE.

C# regex to get video id from youtube and vimeo by url

below is what I am using currently.

<label for="you_tube">Video (Your YouTube URL):</label>
<asp:TextBox placeholder="YouTube URL to your Video" runat="server" ID="you_tube" MaxLength="150" /><br/>
<asp:RegularExpressionValidator ID="regExYouTube" SetFocusOnError="true" runat="server" ErrorMessage="Format should follow: http://youtu.be/8-qxGN4VWzY or http://www.youtube.com/watch?v=33aZX7qxgcw" CssClass="formError" ControlToValidate="you_tube" ValidationExpression="http(s)?://(www\.)?(youtu\.be|youtube\.com)[\w-/=&?]+"  Display="Dynamic" />
Community
  • 1
  • 1
CarterMan
  • 257
  • 1
  • 3
  • 16

1 Answers1

1

The documents on msdn lead me to believe this should work... Anyways, a simple work around is to modify your current regex (currentRegex|^$) to accept an empty string in addition to the two accepted url formats.

Another solution can be found here; http://forums.asp.net/t/1657041.aspx/1

To summarize, you start with the validator disabled, then enable it when the TextChanged event is fired.

evanmcdonnal
  • 46,131
  • 16
  • 104
  • 115