检查数字 [英] checking for a digit

查看:79
本文介绍了检查数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查在文本框中输入的第一个和最后一个字母是否为数字

I want to check whether the first and the last letters entered in a textbox are digits or not

推荐答案

您应在文本框中使用以下正则表达式文字:

\ d.* \ d
You should use the following regular expression against the text box text:

\d.*\d


您可以使用正则表达式验证器.

You can use regular expression validator.

<asp:TextBox ID="txtStringFirstLast" runat="server"></asp:TextBox>
               
               
                <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"

                    ControlToValidate="txtStringFirstLast" ErrorMessage="first and last letter must be digit."

                    ValidationExpression="^\d\w*\d


" > < >



您可以在此处下载正则表达式生成器以创建任何正则表达式并对其进行测试: [ http://sourceforge.net/projects/regexbuilder/files/]



You can download regular expression builder here to create any regular expression and test it: [http://sourceforge.net/projects/regexbuilder/files/]


这篇关于检查数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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