Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

regex for dollar amount including sign

Kumar38
Kilo Sage

Hi,

I need to have a regex validation on a variable that Should accept dollar ammounts like $20.01 etc.

I used this  /^\$(?![.0]*$)\d+\.\d{2}$/ , but it accepts only 20.01 as a valid input , I would like it to accept dollar sign too

1 ACCEPTED SOLUTION

@Kumar38 

 

Try this '(\$[0-9]+(.[0-9]+)?)' and let me know if it didn't worked. 

 

Please mark the answer as helpful if it helped you accordingly!

 

Thanks,

Hari

View solution in original post

4 REPLIES 4

Hari Prasath
Tera Guru

Hi @Kumar38 ,

 

You can try using this regex /^[0-9.,]+$/ . Please let me know if it didn't worked. 

 

Please mark the answer as helpful if it helped you accordingly!

 

Thanks,

Hari

It Says not a valid update , when I put this in "Question Regular Expression"

@Kumar38 

 

Try this '(\$[0-9]+(.[0-9]+)?)' and let me know if it didn't worked. 

 

Please mark the answer as helpful if it helped you accordingly!

 

Thanks,

Hari

thank you this one without the ' ' worked... 🙂