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

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -