Validating textbox in vb net
In fact, this technique can only enforce field-level validation; it does nothing for record-level validation.
The second flaw is that the Validate event doesn't fire when you're moving the focus from a control whose Causes Validation property is False, even if the control that receives the focus has its Causes Validation property set to True. Now you can ask questions directly to me on my new site ASPForums. Net Question Answer site, specially started to allow visitors of this site ask their doubts and queries. Just click the Ask Now button and ask your question now.Because the second field's Causes Validation property is True, Visual Basic fires a Validate event in the first Text Box control: Private Sub txt Required_Validate(Cancel As Boolean) ' Check that field is not empty. Text = "" Then Msg Box "Please enter something here", vb Exclamation Cancel = True End If End Sub If the Cancel parameter is set to True, Visual Basic cancels the user's action and takes the input focus back on the txt Required control: No other Got Focus and Lost Focus events are generated.On the other hand, if you typed something in the required field, the focus will now be on the second field (the numeric text box).