如何在Dynamics CRM 2011中将输入值与正则表达式匹配? [英] how to match a input value with the regular expression in dynamics crm 2011?
本文介绍了如何在Dynamics CRM 2011中将输入值与正则表达式匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在联系表上,我有一个字段名称为Extension(new_ext)。在onChnage事件中,我想检查天气,用户输入了数字或其他任何东西。我有以下代码。
At the contact form I have a field name as Extension (new_ext). and at the onChnage event I want to do check weather the user has enter the number or anything else. I have the following piece of code.
function formatPhone(phonenum)
{
var ext =phonenum.getEventSource().getValue();
var reg = /^[0-9]$/;
if(ext.match(reg))
{
alert("Valid");
}
else
{
alert("invalid");
}
}
即使我输入字母,它也总是无效
It returns me always invalid even if I enter a letter or a number or both.
我想寻求您对此的建议和帮助。
I want to seek your kind suggestions and help regarding this.
推荐答案
试试这个 ^ \d + $
,只是在需要之前检查空值。
Try this one "^\d+$"
, just check for null values before if you need to.
已在此处问过正则表达式允许字符串仅包含数字0-9
这篇关于如何在Dynamics CRM 2011中将输入值与正则表达式匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文