c# - Validating Positive number with comma and period -


i need regular expression validation expression will

allow

  • positive number(0-9)
  • , , .

disallow

  • letter(a-z)
  • any other letter or symbol except . , ,

for example, on asp.net text box, if type anything@!#--, regular expression validation disallow it, if type 10.000,50 or 10,000.50 should allowed.

i've been trying use regex:

^\d+(\.\d\d)?$ 

but textbox must allow , symbol , tried using integer regex validation, did disallow if type string, disallow . , , symbol while should allow number(0-9) , . , , symbol

your regex be,

(?:\d|[,\.])+ 

or

^(?:\d|[,\.])+$ 

it matches 1 or more numbers or , or . 1 or more times.

demo


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -