private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { { if (!(char.IsDigit(e.KeyChar) || char.IsControl(e.KeyChar))) { e.Handled = true; MessageBox.Show("ประเภทข้อมูลต้องเป็นตัวเลขเท่านั้น!!!"); } } }
Quote:ไปทำตอนกดปุ่มบันทึก ก็ได้นี่คะ พอกดปั้บก้อวิ่ง checked ความยาว >> textboxXXX.Text.Length ถ้าไม่ถึง 13 ก้อไม่ยอมให้ save มี message box ออกมาอะค่ะ
private bool VerifyCitizenID(string citizenID) { //ตรวจสอบว่าทุก ๆ ตัวอักษรเป็นตัวเลข if (citizenID.ToCharArray().All(c => char.IsNumber(c)) == false) return false; //ตรวจสอบว่าข้อมูลมีทั้งหมด 13 ตัวอักษร if (citizenID.Trim().Length != 13) return false; int sumValue = 0; for (int i = 0; i < citizenID.Length - 1; i++) sumValue += int.Parse(citizenID[i].ToString()) * (13 - i); int v = 11 - (sumValue % 11); return citizenID[12].ToString() == v.ToString(); }
Quote:ตงไหนติดก้อก้อบมาดิคะ cap screen error มาด้วย
if (textBox3.Text.Length) { MessageBox.Show("กรุณาตรวจสอบข้อมูลของท่านใหม่ค่ะ"); }
if (VerifyCitizenID(textBox3.Text)) { MessageBox.Show("กรุณาตรวจสอบข้อมูลของท่านใหม่ค่ะ"); }
string strRegex = @"(\d-\d{4}-\d{5}-\d{2}-\d)"; Regex myRegex = new Regex(strRegex, RegexOptions.None); string strTargetString = @"1-2345-67890-12-3"; foreach (Match myMatch in myRegex.Matches(strTargetString)) { if (myMatch.Success) { // Add your code here } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง