Hey all,
Am after a bit of help using regular expression.
I have 4 Text Boxes that i would like to validate before data is stored in database.
If i hit add with no values in the text boxes, the only error message that is displayed is the first one. How can i make it that the error is stored and displayed once all text boxes are checked?
Am after a bit of help using regular expression.
I have 4 Text Boxes that i would like to validate before data is stored in database.
Code:
If Not Regex.IsMatch(txtSaleID.Text, "(?s)^\d{6}$") Then
MsgBox("Please enter a valid Sale ID (Numbers Only")
txtSaleID.Select()
Exit Sub
End If
If Not Regex.IsMatch(txtproductid.Text, "(?s)^(P)\d{6}$") Then
MsgBox("Please enter a valid Product ID (Valid Product ID PXXXXXX)")
txtproductid.Select()
Exit Sub
End If
If Not Regex.IsMatch(txtqty.Text, "(?s)^\d$") Then
MsgBox("Please enter a valid QTY (numbers only)")
txtqty.Select()
Exit Sub
End If
If Not Regex.IsMatch(txtcustomerid.Text, "(?s)^\d$") Then
MsgBox("Please enter a valid Customer ID (numbers only)")
txtqty.Select()
Exit Sub
End If