javascript - Filtering out 0-9 & dashes only? -


i create regexp targets characters in string isn't 0-9 (numeric) or - (dash). wrong below regexp?

regex:

regex = '/^[0-9-]/g'; 

js implementation:

$(this).val($(this).val().replace(regex, '')); 

i think meant ^ inside character class. also, regexes not strings:

regex = /[^0-9-]/g; $(this).val($(this).val().replace(regex, '')); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -