You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -318,7 +318,7 @@ displays 100 as: **$100/kg**
318
318
#### Miscellaneous JavaScript Properties and Methods:
319
319
- `text` (read-only) is the formatted text value, including currency, units, etc.
320
320
- `useLocale` (read-only) returns `true` if `locale` is set.
321
-
- `validate` is a `Function` for custom validation or transformation.
321
+
- `validate` is a `Function` for custom validation and/or transformation.
322
322
- `resize(forceIt)` resizes the element. When `autoResize` is `true`, it runs automatically after setting any attribute that affects the element's width or alignment. When `autoResize` is `false`, you must set `forceIt` to `true` or the function won't run. Call it after you change CSS font properties, for example.
323
323
324
324
### Events
@@ -334,10 +334,11 @@ When the user inputs via the spinner, the event object has two additional proper
334
334
- `isSpinning` is set to `true`.
335
335
- `isUp` is `true` when it's spinning up (incrementing) and `false` or `undefined` when spinning down (decrementing).
336
336
337
-
The `validate` property allows you to insert your own validation (or transformation) function before the value is committed and the `change` event is fired. Because it runs before committing the value, it runs before the internal `!isNaN()` validation. The function takes two arguments: `value` and `isSpinning`. `value` is a string (keyboard input) or a number (spinning). The return value falls into three categories:
338
-
- `false` for invalid values
339
-
- `undefined` or `value` to accept the current value
340
-
- a different number: for when you want to round to the nearest prime number, or perform whatever transformation or restriction that can't be defined solely by `max` and `min`.
337
+
The `validate` property allows you to insert your own validation and/or transformation function before the value is committed and the `change` event is fired. Because it runs before committing the value, it runs before the internal `!isNaN()` validation. The function takes two arguments: `value` and `isSpinning`:
338
+
- `value` is a string (keyboard input) or a number (spinning)
339
+
- `isSpinning` is a boolean indicating whether the user is inputting via keyboard (`false`) or the spinner (`true`).
340
+
341
+
To indicate an invalid value, return `false`. Otherwise return the value itself, transformed or not. Transforms are for those rare occasions when you want to round to the nearest prime number, or whatever transformation or restriction that can't be defined solely by `max` and `min`.
341
342
342
343
### Styling
343
344
You can obviously style the element itself, but you can also style some of its parts via the `::part` pseudo-element. Remember that `::part` overrides the shadow DOM elements' style. You must use `!important` if you want to override `::part`.
0 commit comments