0
我想跳過驗證的一部分,只是讓文本框不能有任何我不想要的東西。vb.net textbox沒有特殊字符
其意圖是允許輸入後退,空格和字母:d,r,i(上和下)。
我怎樣才能讓這個沒有特殊字符獲取進入像{},:;與一對夫婦如果塊的過濾數據」等
Private Sub txtParty_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtParty.KeyPress
'allows only numbers, letter, space, and backspace
If Char.IsControl(e.KeyChar) = False And Char.IsSeparator(e.KeyChar) = False And Char.IsLetterOrDigit(e.KeyChar) = True And e.KeyChar <> "d" And e.KeyChar <> "D" And e.KeyChar <> "r" And e.KeyChar <> "R" And e.KeyChar <> "i" And e.KeyChar <> "I" Then
e.Handled = True
End If
End Sub
你可以使用與客戶端驗證的正則表達式。這是ASP。淨W eb表單? – Win
從MSDN向TextBox添加正則表達式驗證https://msdn.microsoft.com/zh-cn/library/ms996428.aspx –