javascript - Why my Regex let me write "," (Comma)? -
i have javascript regex function code above:
function acceptdigits(objtextbox) { var exp = /[^\d{1,3}]/g; objtextbox.value = objtextbox.value.replace(exp, ''); };
always write special character function remove character example:
i write 45656654@ , function clean "@" 45656654.
my problem
the problem when write "," (comma) function not work, try ".-()/&%$#" , function work.
any catch , remove comma?
/[^\d{1,3}]/g
means "a single character neither digit, curly brace nor comma".
you meant
/\d{1,3}/g
but actually, if want use regex replace non-digits, use
/\d+/g
Comments
Post a Comment