javascript - remove dash in phone number within razor -


i need call javascript method , using razor print parameters...

getnumber(@html.displayfor(model => model.phone1)"> 

however, javascript treats dash in phone number subtraction operator.

i tried regular expression remove dash, can't figure out right syntax. still performs subtraction operation , gives me javascript error [subtration result].replace not function

getnumber((@html.displayfor(model => model.phone1)).replace(/[^0-9.]/g, ''))"> 

you should treat phone numbers strings, make sure javascript knows number string enclosing in quotes:

getnumber('@html.displayfor(model => model.phone1') 

this should rendered this:

getnumber('1-800-call-me') 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -