不是asp.net或驗證專家。但是,角色類僅需要某些字符,如[]
。破折號-
代表一系列字符。如果用作文字,它可以被轉義並放在任何地方,或者可以放在課程的開始或結尾([-aa]
或[aa-]
),並被視爲文字。此外,在課程開始處插入一個脫字號,表示「否定」類的含義,但是這些字符([^not me]
)。
有可能是在課堂上其他構造獨特,以特定的發動機特殊的語法(.NET可能是這個樣子,我不知道)。我猜想某些序列也觸發了一個子類。
這裏是我的測試情況下與使用特殊字符asp.net驗證。他們可能是相關的,我不確定。兩者似乎都不驗證空白輸入,這可能不是正則表達式。
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Input is not valid."
ValidationExpression="^.*[\[\]^$.|?*+()\\~`[email protected]#%&\-_+={}'"<>:;,\ ].*$"></asp:RegularExpressionValidator>
<asp:Button ID="Button1" runat="server" Text="Button" />
這一個似乎照顧了一個安全問題,如果這相關。請注意0,其中'alpha'表示根據我認爲符合某些標準的一系列有效unicode字符。
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Input is not valid."
ValidationExpression="^(?!.*<(?:/|[A-Za-z_:])).*[\[\]^$.|?*+()\\~`[email protected]#%&\-_+={}'"<>:;,\ ].*$"></asp:RegularExpressionValidator>
<asp:Button ID="Button1" runat="server" Text="Button" />
只是無視這種情況。
來源
2012-02-22 01:06:56
sln
我討厭那種需要ID和密碼包含特殊字符的網站 – 2012-02-21 22:15:11
只是一個側面說明:如果你起訴ASP.NET會員,您可以使用['MinRequiredNonAlphanumericCharacters'](http://msdn.microsoft.com/en-us/library/system.web.security.membership .minrequirednonalphanumericcharacters.aspx)-property以確保在密碼中輸入特殊字符。 – 2012-02-21 22:19:52
@TimSchmelter - noooo,不起訴微軟:)爲什麼我不能在成員資格提供者中使用這個,是因爲這個驗證是可選的 - 它可以打開或關閉,這取決於客戶的需求......我們不會能夠爲我們的應用程序的所有客戶端強制執行它。謝謝你的旁註..雖然.. – Alex 2012-02-21 22:31:51