1

I have 2 questions regarding MVC view validation using System.ComponentModel.DataAnnotations:

  1. How do I verify if a value entered in a text box is a URI?

  2. How can I verify using RegularExpression if the URL entered in a Box does not start with HTTP:// or ends with ".m3u8"

1

1 Answer 1

1

Try something like this

[RegularExpression(@"((((ht)tp?:\/\/)?[^\/\s]+\.(m3u8))(\/\S*)?)", ErrorMessage="Not a Valid URL")]
public string URL { get; set; }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.