A form demonstrating different number field types: integer fields for whole numbers, decimal fields for precise measurements, and money fields with currency formatting.
Every code snippet below is fully editable! Feel free to modify the code, experiment with different values, and see your changes reflected instantly in the live preview on the right.
Use the play button to run different snippet, or the refresh button to restore the original example.
Let's start with an empty form function. This is where we'll build our number fields form step by step.
First, let's add an integer field for age. Integer fields only accept whole numbers and are perfect for counts, ages, quantities, etc.
addInteger() and only accept whole numbers. The min and max properties provide validation boundaries. Now let's add a decimal field for height. Decimal fields accept fractional numbers and are great for measurements, percentages, and precise calculations.
addDecimal() and accept fractional numbers. The step property controls the increment size (0.01 for centimeters). Let's add a money field for salary. Money fields provide automatic currency formatting and are perfect for financial data.
addMoney() and automatically format values with currency symbols. The currency property sets the symbol (defaults to 'USD'). Finally, let's add another money field with different currency and step values. Notice how different currencies and step sizes affect the input behavior.
step property can be fractional for precise pricing (0.01 for cents). Excellent! You've mastered number fields and their different types. Ready to explore more advanced form features?
Continue to Selection Fields TutorialOther learning paths: