Windows应用程序中文本框的问题.请紧急 [英] problem with textbox in windows applications. it's urgent please

查看:72
本文介绍了Windows应用程序中文本框的问题.请紧急的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii

我可以输入字符和数字,如果我同时输入字符和数字,则仅应提交表格,否则不可以.假设我输入完整的字符或输入完整的数字,则不应提交表格.....如果我同时输入两者,则仅应在基于Windows的应用程序中提交表格


谢谢

hii

i am able to enter charecters and digits, if i enter both charecters and digits then only the form should submit otherwise it shouldn''t. suppose if i enter complete charecters or if i enter complete digits the form should not submit.....if i enter both only the form should submit in windows based applications


Thank you

推荐答案

处理文本框的KeyDown/keyPress事件之一,并同时验证数字和文本的文本.
如果它们都不存在,请不要启用提交"按钮.
Handle the one of KeyDown / keyPress events of the textbox and validate the text for numbers and text together.
If both of them are not present, don''t enable the submit button.


我将创建两个正则表达式:一个用于任何字母,一个用于任何数字. 只有两个都匹配时,它才有效.
I would create two regexes: one for any letter, one for any digit.
Only if both match does it validate.
string instr = "abc123";
Regex letters = new Regex("[a-zA-Z]");
Regex numbers = new Regex("[0-9]");
if (letters.IsMatch(instr) && numbers.IsMatch(instr))
    {
    ...
    }


将keydown事件与两个布尔值一起使用,一个用于数字,一个用于字母,在按下键或按下事件的帮助下,如果您获得数字和字母,则将值分配为true .在单击提交"按钮时,请检查是否具有布尔变量的真值(如果不是),请用户同时输入数字和字母.

谢谢,
Ambesha
Use the keydown event with two bool values one for numeric and one for alphabets, with the help of key down or key press event assign value true if you get number and alphabets. while clicking on submit button check that you have true values of bool variables if not the ask user to enter number and alphabets both.

Thanks,
Ambesha


这篇关于Windows应用程序中文本框的问题.请紧急的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆