You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
727 B

  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. }