WinForm表单验证

思想来源于Jquery表单验证,可以像使用jQuery验证方法来验证winform

ContractedBlock.gif ExpandedBlockStart.gif Code
 1this.textBox1.InputValidate(new InputValidateMetaData()
 2ExpandedBlockStart.gifContractedBlock.gif            {
 3                ValidateGroupName = "Form1",
 4                Type = WinFormValidator.ValidateType.String,
 5                Min = "5",
 6                Max = "10",
 7                ShowMsg = "请输入5-10个字符",
 8                SuccessMsg = "输入正确",
 9                FailedMsg = "输入错误",
10            }
);
11
12            this.textBox2.RegexValidate(new RegexValidateMetaData()
13ExpandedBlockStart.gifContractedBlock.gif            {
14                ValidateGroupName = "Form1",
15                Type = WinFormValidator.ValidateType.Regex,
16                Pattern = @"^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$",
17                ShowMsg = "请输入ip地址",
18                SuccessMsg = "输入正确",
19                FailedMsg = "输入错误",
20            }
);
21
22ExpandedBlockStart.gifContractedBlock.gif            this.textBox3.FunctionValidate(new FunctionValidateMetaData() {
23                Type = ValidateType.Function,
24                ValidateGroupName = "Form1",
25                ShowMsg = "请输入5-10个字符",
26                SuccessMsg = "输入正确",
27                FailedMsg = "输入错误",
28                FunctionEvent = new FunctionEventHandler(functionValidate),
29            }
);

 

转载于:https://www.cnblogs.com/Memory/archive/2009/11/17/1604372.html

你可能感兴趣的:(javascript)