標籤:style blog color 使用 div log text c#
string strErrorMes = null;
if(Validates()){ XXXXX} public bool Validates() { if (this.txtUserName.Text == "") { strErrorMes = "姓名不可為空!"; this.txtUserName.Focus(); errorProvider.SetError(this.txtUserName, strErrorMes); //給errorProvider控制項賦值 } if (this.txtNativePlace.Text == "") { strErrorMes = "籍貫不可為空!"; this.txtNativePlace.Focus(); errorProvider.SetError(this.txtNativePlace, strErrorMes); //給errorProvider控制項賦值 } if (this.txtphone.Text == "") { strErrorMes = "電話不可為空!"; this.txtphone.Focus(); errorProvider.SetError(this.txtphone, strErrorMes); //給errorProvider控制項賦值 } else { string regStr = @"((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)"; bool isRightNo = Regex.IsMatch(txtphone.Text.Trim(), regStr); if (!isRightNo) { strErrorMes = "電話格式錯誤"; txtphone.Focus(); errorProvider.SetError(txtphone, strErrorMes); } } if (strErrorMes != null) {
strErrorMes = null;
return false;
} return true; }