Question Highlighting Text

VentureFree

Well-known member
Joined
Jan 9, 2008
Messages
54
Programming Experience
5-10
I've got a form (aspx) with a survey. One question in particular requires a text answer with less than 50 chars. I've set
VB.NET:
TextBox1.MaxLength = 50
but it still seems to allow the entry of more than 50 chars (I would have thought that at 50 chars it would stop accepting characters, but apparently not). Since that doesn't work, I figured I'd highlight all text past 50 chars on the TextChanged event to make it obvious to the user that they need to change at least that much of their answer. How do I go about doing that? I've seen other places mention using
VB.NET:
TextBox1.Select(#, #)
but that option doesn't seem to be available to me. Any idea why?
 
regex validator is best way but u can

textchanged event
VB.NET:
if textbox1.text.length > 50 then
label1.text = "Maximum 50 characters please!"
end if
label1.text += " - You currently have " & textbox1.text.length & " characters"
end sub

i dont see the point in selecting the last part of the string :/
 

Latest posts

Back
Top