 
 (defn- hyphenation-pattern-edit-ui
   [word new-hyphenation stop save]
-  [:tr
-   [:td word]
-   [:td
-    [:input.form-control
-     {:type "text"
-      :auto-focus true
-      :on-change #(reset! new-hyphenation (-> % .-target .-value))
-      :on-key-down #(case (.-which %)
-                      27 (stop)
-                      nil)
-      :value @new-hyphenation}]]
-   [:td
-    [:div.btn-group
-     [:button.btn.btn-default
-      {:on-click save}
-      [:span.glyphicon.glyphicon-ok {:aria-hidden true}] " Save"]
-     [:button.btn.btn-default
-      {:on-click stop}
-      [:span.glyphicon.glyphicon-remove {:aria-hidden true}] " Cancel"]]]])
+  (let [valid? (hyphenation-valid? @new-hyphenation word)
+        klass (if valid? "form-group" "form-group has-error")]
+    [:tr
+     [:td word]
+     [:td
+      [:div
+       {:class klass}
+       [:input.form-control
+        {:type "text"
+         :auto-focus true
+         :on-change #(reset! new-hyphenation (-> % .-target .-value))
+         :on-key-down #(case (.-which %)
+                         27 (stop)
+                         nil)
+         :value @new-hyphenation}]
+       (when-not valid?
+         [:span.sr-only "(error)"])]]
+     [:td
+      [:div.btn-group
+       [:button.btn.btn-default
+        {:on-click save}
+        [:span.glyphicon.glyphicon-ok {:aria-hidden true}] " Save"]
+       [:button.btn.btn-default
+        {:on-click stop}
+        [:span.glyphicon.glyphicon-remove {:aria-hidden true}] " Cancel"]]]]))
 
 (defn hyphenation-pattern-item-ui [{:keys [hyphenation] :as pattern}]
   (let [editing (reagent/atom false)


(defn hyphenation-ui []
  (let [label "Corrected Hyphenation"
        valid? (or (string/blank? @hyphenation) (hyphenation-valid? @hyphenation))
        klass (if valid? "form-group" "form-group has-error")]
    [:div
     {:class klass}
     [:label {:for "hyphenationInput"} label]

(defn- hyphenation-add-ui []
  [:div.form-group
   [:button.btn.btn-default
    {:on-click #(when (and (not (string/blank? @word))
                           (hyphenation-valid? @hyphenation @word))
                  (add-hyphenation-pattern! {:word @word :hyphenation @hyphenation :spelling @spelling}))
     :disabled (when (or (string/blank? @word)
                         (not (hyphenation-valid? @hyphenation @word))
                         (= @hyphenation @suggested-hyphenation))
                 "disabled")}
    "Add"]])
