123456789101112131415161718192021222324252627282930313233343536 |
- /* ==============================================================================
- * 功能描述:浮点数字,正数和负数
- * 创 建 者:Garrett
- * 创建日期:2018/2/28 14:53:43
- * ==============================================================================*/
- using System;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text.RegularExpressions;
- namespace WPG.MBIPropType
- {
- public class AccessDecimal : BaseTextInputControl
- {
- public override bool InputControl(string fullText)
- {
- string pattern = @"^-?(([1-9]\d*\.\d+)|(0\.\d+)|([1-9]\d*)|(0))$";
- Regex regex = new Regex(pattern);
- if (fullText.Length == 1)
- {
- if (!"-".Equals(fullText) && !regex.IsMatch(fullText))
- {
- return false;
- }
- return true;
- }
- if (regex.IsMatch(fullText))
- {
- return true;
- }
- return (((fullText.Count<char>((c)=> c=='.') == 1) && (fullText.IndexOf('.') == (fullText.Length - 1))) && (fullText.IndexOf("-.") < 0));
- }
- }
- }
|