开发者

Having trouble with javascript Replace()

This code will replace the comma's no problem, but will leave the $ for some reason... Is it set开发者_JAVA技巧 up wrong? Trying to replace the $ also.

function doValidate() { 
    var valid = true;  
    document.likeItemSearchForm.sup.value = document.likeItemSearchForm.sup.value.replace(/\$|,/g, "")  
    return valid;   
}


Try this:

'asd$asd,asd,asd$,asd'.replace(/[\$,]/g,'');

JSFIDDLE -edit- fixed link


try this:

"$12,121.30".replace(/[\$,]/g, "");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜