//Convert text to uppercase
this.DeliveryTermCodeTextBox.Text = this.DeliveryTermCodeTextBox.Text.ToUpper();
//Put the cursor on the last
this.DeliveryTermCodeTextBox.SelectionStart = this.DeliveryTermCodeTextBox.Text.Length;
//Restrict the user to input Chinese
Regex r = new Regex(@"^[A-Za-z0-9]+$");
Match mh = r.Match(this.DeliveryTermCodeTextBox.Text.Trim());
if (!mh.Success && this.DeliveryTermCodeTextBox.Text.Length > 0)
{
//If the user enters the Chinese replaced with empty
this.DeliveryTermCodeTextBox.Text = this.DeliveryTermCodeTextBox.Text.Replace(
this.DeliveryTermCodeTextBox.Text.Substring(this.DeliveryTermCodeTextBox.Text.Length - 1, 1), "");
MessageBox.Show("只可輸入英文和數字");
this.DeliveryTermCodeTextBox.Focus();
}
this.DeliveryTermCodeTextBox.Text = this.DeliveryTermCodeTextBox.Text.ToUpper();
//Put the cursor on the last
this.DeliveryTermCodeTextBox.SelectionStart = this.DeliveryTermCodeTextBox.Text.Length;
//Restrict the user to input Chinese
Regex r = new Regex(@"^[A-Za-z0-9]+$");
Match mh = r.Match(this.DeliveryTermCodeTextBox.Text.Trim());
if (!mh.Success && this.DeliveryTermCodeTextBox.Text.Length > 0)
{
//If the user enters the Chinese replaced with empty
this.DeliveryTermCodeTextBox.Text = this.DeliveryTermCodeTextBox.Text.Replace(
this.DeliveryTermCodeTextBox.Text.Substring(this.DeliveryTermCodeTextBox.Text.Length - 1, 1), "");
MessageBox.Show("只可輸入英文和數字");
this.DeliveryTermCodeTextBox.Focus();
}