5 min read
How to format a price input in Webflow
![How to format a price input in Webflow](https://cdn.prod.website-files.com/60e2dd6643b87eb91114618e/641cd44b5a9e4f73a1a686f9_How%20to%20format%20a%20price%20input%20in%20Webflow%20(1).webp)
Related articles:
See how to format a price input in Webflow in action: https://how-to-webflow-clonable.webflow.io/custom-price-number-formatting-in-webflow
1) Create the input field
- Insert Form element to the Webflow
- Style it
- Make sure the ID of the element is "application-form-income"
- Make sure the type of the form is "Plane" NOT "number"
![](https://cdn.prod.website-files.com/60e2dd6643b87eb91114618e/641cd0525a9e4f2984a632a5_How%20to%20format%20a%20price%20input%20in%20Webflow.webp)
2) Add Javascript
- Open the Pages
- Open settings of the page
- Before the </body> add following code
3) Code explain
![](https://cdn.prod.website-files.com/60e2dd6643b87eb91114618e/641cd23e945486b2ace93468_image1.png)
This line will fetch the input element
![](https://cdn.prod.website-files.com/60e2dd6643b87eb91114618e/641cd2878bcca1055ed6af3e_image2.png)
This function will
- Target the input
- Replace all the non-numeric elements
- Remove zeros if they are leading (try it - you will not be able to type 0 when is empty)
- Formats the user's input to display as a currency value by calling the formatNumber function.
![](https://cdn.prod.website-files.com/60e2dd6643b87eb91114618e/641cd399de3477675c532ab8_image3.png)
The last function takes a number as an argument and formats it as a currency value. The function uses a regular expression to add commas to separate thousands, and returns the formatted value.
Subscribe to newsletter
Subscribe to receive the latest blog posts to your inbox every week.
Website pre-launch checklist
69 steps pre-launch checklist is the most complex checklist developed by years of experience in Karpi Studio.
You will find how to test and fix:
- loading speed issues,
- responsivity issues on all current devices,
- SEO issues,
- and many more.
€30 Now: €9.00
Check it now