A way better approach for form validation. Feels good now.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
[react :as react]))
|
||||
(def good-$ #"^\-?[0-9]+(\.[0-9][0-9])?$")
|
||||
|
||||
(defn -money-field [{:keys [min max disabled on-change value class style placeholder]}]
|
||||
(defn -money-field [{:keys [min max disabled on-blur on-change value class style placeholder]}]
|
||||
(let [[ parsed-amount set-parsed-amount] (react/useState {:parsed value
|
||||
:raw (cond
|
||||
(str/blank? value)
|
||||
@@ -59,7 +59,9 @@
|
||||
|
||||
(set-parsed-amount {:raw ""
|
||||
:parsed nil})
|
||||
(on-change nil)))
|
||||
(on-change nil))
|
||||
(when on-blur
|
||||
(on-blur)))
|
||||
:min min
|
||||
:max max
|
||||
:step "0.01"
|
||||
|
||||
Reference in New Issue
Block a user