Subject: Validation
Posted By: Sheikha Post Date: 9/14/2004 12:42:11 AM
Hi:

i want to set validation in text boxes in VB.NET. For example, i have a text box that can take a maximum of 3 digits. before you insert a record by clicking on a button, it validates all text boxes. how do i do that?

code that i wrote:

If (Not IsNumeric(txtSubAreaNo.Text)) Then
            lblComment.Text = "Please enter a numeric SubArea Number"

this text box should only allow 3 digits maximum to be entered.

Thanks in advance
Reply By: netsjp Reply Date: 9/14/2004 1:06:27 AM
for each ctl in me.controls
    if ctl.gettype="TextBox" ctl.MaxLenth=3
next

Reply By: Ramakrishna.G Reply Date: 9/14/2004 3:57:18 AM
 you try to use regular expressions, i think this is the beter way.
steps.
 1. frist drag the regular expression validatior,
 2. go to properties window and set the controle to validate to your text box
 3. write regular expression at validation expression in properties window

  for maximum of three digits the expression is:  ^\d{1,3}$
any number that is 1 to 3 digits in length.eg:matches 1, 15, or 987.



Reply By: stu9820 Reply Date: 9/14/2004 7:23:54 AM
You can use a range validator.  They are designed for that.

Reply By: pradeep_itguy Reply Date: 10/8/2004 4:05:08 AM
Go to the following page for more information about the validator control creation

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet04082003.asp?frame=true




It is not how much we do,
but how much love we put in the doing.

-Mother Theresa

Go to topic 20161

Return to index page 750
Return to index page 749
Return to index page 748
Return to index page 747
Return to index page 746
Return to index page 745
Return to index page 744
Return to index page 743
Return to index page 742
Return to index page 741