Given is the validation code for my form.
private void button1_Click(object sender, EventArgs e) {if (txtName.Text == string.Empty) {MessageBox.Show("Enter the name");txtName.Focus(); }if(dateTimePicker1.Value.Date > DateTime.Now) {MessageBox.Show("Invalid date"); } if (!rbtMale.Checked && !rbtFemale.Checked) {MessageBox.Show("Choose the gender"); }if (txtAddress.Text == "") {MessageBox.Show("Enter the address");txtAddress.Focus(); }if (txtContact.Text == "") {MessageBox.Show("Enter the contact info"); }if (cmbCountry.Text == "") {MessageBox.Show("CHoose your country"); } }
What i want to do is just show one message box saying form is not filled. And to highlight the empty fields.