Hello: I've been using KeyPress to help limit what the user enters into certain textboxes. e.g. here's my code for a Phone number. It only allows for numbers and dashes:
It's all working fine; however, the thing I hate about using it is that when ever have to do debugging of the screen, for each keypress into this textbox, it goes into debug.HTML Code:Private Sub txtPhone_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPhone.KeyPress If Not (Char.IsWhiteSpace(e.KeyChar) Or (Asc(e.KeyChar) = 45) Or Char.IsDigit(e.KeyChar) Or (Asc(e.KeyChar) = 8)) Then '45 is dash 8 is backspace lblMask.Visible = True lblMask.Text = "Only numbers and dashes allowed." e.Handled = True Else e.Handled = False End If lblValidate.Text = "" End Sub
I'm wondering if it's possible to do something similar when the user clicks the save button. Has anyone done any type of validation like this?
thanks for your inputs,
Proctor




Reply With Quote