Prevent special characters in a TextBox

前端 未结 6 1502
一生所求
一生所求 2020-12-19 22:55

I want to prevent users from entering url\'s (like a href=\"\") in a TextBox.

I want to use a regular expression validator but no idea what to write?

How ca

6条回答
  •  失恋的感觉
    2020-12-19 23:20

    As you mention ASP.NET you might want to try a Regex Validator which checks the input to ensure there are no URL patterns present. Have a look at this MSDN Article.

    This regex should do the trick: @"^(?!.*(mailto\:|(news|(ht|f)tp(s?))\://).*).*$"

提交回复
热议问题