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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -