1
Answer

value validation

sachi vasishta

sachi vasishta

15y
1.8k
1

Hi,

I have a winform that contains the following

4 textboxes and a button.

a)first name b)ssn c)lastname d)city e)zip

 here if  the user doesnot enter the values for first name and/or last name then it should give a message saying please enter the first name and/or last name . And the zip field's value is 5 characters so if the user enters lessthan or morethan 5 characters then again it should give a message saying zip values is too short or too long.

 

 

Answers (1)
0
Vimal Kandasamy

Vimal Kandasamy

NA 2.3k 152.3k 15y
Hi,

In a button click event

you simply check like
firstname.Text.Lengh<1
or firstname.Text==""

[firstname refers Textbox]...
for zip
if(zip.Text.Length==5))
{
//add you code
}
else
MessageBox.Show("zip must be 5 chars","Error");

[zip refers Textbox]

you can combine these conditions with the help of && operator
try it..