UmarAbbasKhan UmarAbbasKhan - 1 year ago 62
HTML Question

How to select number integers from a string sequence wise from left to right in javascript

I have an input element in which users are to enter the price of the product.

<input size=10 type="text" id="prd_price" title="prd_price" name="prd_price">

My users can enter the Currency Symbols aswell as other things and I am not allowed to stop them from doing this. I have to just select the numbers and form the value of the price from their input string, whether they enter currency symbols in front or after the price or also make the input string comma formatted like 1,000.00.

Can anyone help me to find if their is a javascript function from which I can scoop up the number integers from the input string sequentially from left to right?

Answer Source

that's easy

alert(new Number("blah 12345,;(,84".match(/(?:\d+|\.)/g).join("")))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download