Check if a string contains a specific number in JavaScript

Possible Duplicate:
JavaScript: string contains

I want to check if a string contains a specific number in JavaScript, how can I rewrite the statement s contain d in below code?

var s = '11/14/2012';
var d = '14';
if (s contain d) {
    //...
}

My case is similar to Check if a string contains a certain number, but how can I implement this action in JavaScript?

Thanks


更简单的方法是使用index Of。

if(s.indexOf(d) > -1)

var s = '11/14/2012';
var d = '14';
if (s.match(d)) {
   alert('Found');
}​
链接地址: http://www.djcxy.com/p/2062.html

上一篇: JavaScript:检查字符串是否包含'。' (满满的

下一篇: 检查一个字符串是否包含JavaScript中的特定数字