               (tu/replay new)
               ;; remove old account
               (ar/rm-acc old)))
-          (reset! app-state (new-state nil "" nil))))))
+          (acc-add {:name nm :parent parent :init-bal bal :bal bal})
+          (reset! app-state (new-state nil "" nil)))
+      (u/alert "Please correct errors first!"))))
 
 (defn snd [e] (when (snn e) (reset! g/app-page {:page :home})))
 

;; helpers

(defn name-ob [e]
  (let [val (u/trim-empty? app-state (.-value (.-target e)) :name)
        accs (au/accs->names @g/accounts)]
    (cond (= val "")
          (u/alert "Account name cannot be empty!")

          (u/contains (str/join " " accs) (str (.-value (u/by-id "parent")) ":" val))
          (u/alert "An account with the same name (and parent) already exists!")

          :else
          (swap! app-state assoc :name val))))

(defn amt-ob [e t]
  (if-let [f (u/amt-validate? (.-value (.-target e)))]
    (let [amt (if (= val "") 0 f)]
      (swap! app-state assoc
             :bal amt))
    (u/alert "Only numbers and decimal allowed!")))

(defn acc-add [acc]
  (swap! g/accounts


(defn c-add []
  (let [edit? (:edit? @app-state)]
    [:div [:div.form-group [:label "Parent Account"]
           (if edit?
             [:input.form-control {:type "text"
                                   :id "parent"
                                   :disabled true
                                   :value (:parent @app-state)}]
             [:select.form-control {:id "parent"
                                    :value (:parent @app-state)}
              (for [an (au/accs->names @g/accounts)]
                ^{:key (u/random)}[:option {:value an} an])])]
     [:div.form-group [:label "Account Name"]
      [:input.form-control {:type "text"
                            :id "name"
                            :placeholder (:name @app-state)
                            :onBlur name-ob}]]
     [:div.form-group [:label "Initial Balance"]
      [:input.form-control {:type "text" :id "init-bal" :placeholder 0
                            :onBlur amt-ob}]]
