parseFloats within text input
Parse any float within a text by simply calling the method:
Code:
parseFloats('This was our 10th anniversary and I have spent $812,34 on a fancy dinner at the best 7th avenue restaurant.');
Ouput:
[ 10, 812.34, 7, min: 7, max: 812.34 ]
Use the convenience attributes min and max to retrieve the high and low values from the generated array. Works great for currencies ;)
gist: parseFloats.js
Written by Marcus Zanona
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Parse
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#