[RESOLVED] How to set Minimum character[HELP]
How would i set a minimum number of characters in textbox1 for a button to work. and if the person does not enter the minimum number of characters, a messagebox pops up sayin something like "need at least 5 characters!" Thanks
Re: How to set Minimum character[HELP]
Set the button initially to disabled and try this:
vb.net Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Me.Button1.Enabled = (Me.TextBox1.Text.Length > 5)
End Sub
A MessageBox coming up would be really annoying I think from a UI point of view. That said, you could make it so when they click the button it checks the textbox length and then shows the MessageBox.
Re: How to set Minimum character[HELP]
Thx so much it worked !!! +rep
Re: How to set Minimum character[HELP]
Quote:
Originally Posted by
x DeaDLy
How would i set a minimum number of characters in textbox1 for a button to work. and if the person does not enter the minimum number of characters, a messagebox pops up sayin something like "need at least 5 characters!" Thanks
Quote:
Originally Posted by
ForumAccount
Set the button initially to disabled and try this:
vb.net Code:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Me.Button1.Enabled = (Me.TextBox1.Text.Length > 5)
End Sub
A MessageBox coming up would be really annoying I think from a UI point of view. That said, you could make it so when they click the button it checks the textbox length and then shows the MessageBox.
I agree with ForumAccount. The app that I'm currently working on has many of these cases where controls switch from Enabled to Disabled. I think it looks smart.
Re: How to set Minimum character[HELP]
Quote:
Originally Posted by
x DeaDLy
Thx so much it worked !!! +rep
Or
Code:
if len(textbox1.text) < 5 Then
Button1.Enabled=false
Else
Button1.Enabled=True
End If