25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ValidataRule.cs 727 B

2 년 전
1234567891011121314151617181920212223
  1. using HandyControl.Tools.Extension;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading.Tasks;
  9. using System.Windows.Controls;
  10. namespace HKCardIN
  11. {
  12. public class ValidataRule : ValidationRule
  13. {
  14. public override ValidationResult Validate(object value, CultureInfo cultureInfo)
  15. {
  16. if(value.ToString().IsNullOrEmpty()) return ValidationResult.ValidResult;
  17. var reg = Regex.IsMatch(value.ToString(), "\\d+");
  18. if (!reg) return new ValidationResult(false, "请输入正整数");
  19. else return ValidationResult.ValidResult;
  20. }
  21. }
  22. }