Skip to content
Advertisement

validation-remove currency symbol from price

I have this one string, which is actually price, this price value comes with any currency symbol (currency_list), I am trying to remove these currency symbols from price and return only price.

Till now I am able to do it for prefix and suffix currency symbol using below code , everything works till here.

I just want to add one validation where if the symbol is not prefix or suffix like “200$434” in btw, then it should return not valid format. which I am not able to understand how should be implemented.

JavaScript

Normally input string can be

JavaScript

Code:

JavaScript

Advertisement

Answer

You can use regex to achieve your purpose.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement