AccessInteger.cs 962 B

1234567891011121314151617181920212223242526272829303132
  1. /* ==============================================================================
  2. * 功能描述:只能接受整数,包括正数和负数
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/2/28 14:53:43
  5. * ==============================================================================*/
  6. using System.Text.RegularExpressions;
  7. namespace WPG.MBIPropType
  8. {
  9. public class AccessInteger : BaseTextInputControl
  10. {
  11. public override bool InputControl(string fullText)
  12. {
  13. if (fullText == null)
  14. {
  15. return false;
  16. }
  17. string pattern = @"^\-?(0|([1-9]\d*))$";
  18. Regex regex = new Regex(pattern);
  19. if (fullText.Length != 1)
  20. {
  21. return regex.IsMatch(fullText);
  22. }
  23. if (!"-".Equals(fullText) && !regex.IsMatch(fullText))
  24. {
  25. return false;
  26. }
  27. return true;
  28. }
  29. }
  30. }