开发者

Regex not passing the check

The following statement when provider[x].prefixRegExp = /^5[1-5]/ and val = 55 doesn't return true... am I doing something wrong?

if (provider[x].prefixRegExp.test(val)) {
     $('#payment-panel .credit-card-type .'+provider[x].name).addClass('selected')开发者_开发问答.attr('rel', x);
}


/^5[1-5]/.test(55) actually does return true. Make sure that provider[x].prefixRegExp and val are as you expected by adding alert(provider[x].prefixRegExp + ' ' + val); before those lines and alert("it is true, your css or jquery selector is broken"); in the if condition.


Just checked in browser console:

>> /^5[1-5]/.test("55")
<< true

So looks like your val not equals 55 or your provider[x].prefixRegExp not the /^5[1-5]/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜