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, "");
精彩评论