how to match a input value with the regular expression in dynamics crm 2011?

我的未来我决定 提交于 2019-12-12 01:09:24

问题


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.


回答1:


Try this one "^\d+$", just check for null values before if you need to.

Already asked here Regex allow a string to only contain numbers 0 - 9



来源:https://stackoverflow.com/questions/21612600/how-to-match-a-input-value-with-the-regular-expression-in-dynamics-crm-2011

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!