if ((myControl.Text.Length != 7) && (myControl.Name.ToString() == "txtTelNo") && (myControl.Enabled)).
public static bool IsValidLength(Form myform) { foreach (Control myControl in myform.Controls) { if (myControl.GetType() == typeof(TextBox)) { if (IsNumeric(myControl.Text) == true) { if ((myControl.Text.Length != 7) && (myControl.Name.ToString() == "txtTelNo")) { MessageBox.Show(myControl.Name.Substring(3).ToString() + " length is invalid."); myControl.Focus(); return false; }// end of 7 if ((myControl.Text.Length != 7) && (myControl.Name.ToString() == "txtFaxNo")) { MessageBox.Show(myControl.Name.Substring(3).ToString() + " length is invalid."); myControl.Focus(); return false; }// end of 7 if ((myControl.Text.Length != 11) && (myControl.Name.ToString() == "txtMobileNo")) { //myControl.Text = myControl.Text.Trim(); MessageBox.Show(myControl.Name.Substring(3).ToString() + " length is invalid."); myControl.Focus(); return false; }// end of 7 }// end of isnumeric else { if ((myControl.Text.Length < 2) && (myControl.Name.ToString() != "txtSuppNo")) { MessageBox.Show(myControl.Name.Substring(3).ToString() + " length is invalid."); myControl.Focus(); return false; }// end of 2 }// end of else }//end of gettype }//end of foreach return true; }// end of isvalidlength
if ( ((myControl.Text.Length != 7) && (myControl.Enabled)) && (myControl.Name.ToString() == "txtTelNo")
if(!myControl.Enabled) { continue; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)