dominoes endorse

A ClojureScript front-end validation library => https://github.com/runexec/dominoes

Click here to try it live or watch the animated GIF preview (loading)

preview gif animation

Usage Example

(use '[dominoes.core
       :only [document-ready?
              validate!
              valid-submit!
              *error-style*]])

(defn init []
  (when (document-ready?)

    ;; Update error style
    ;; You can also update *error-remove-style*

    (swap! *error-style* assoc :color "red")

    ;; validate object id
(validate! "name-input"
;; error message label object id
"name-error"
;; [event-kw test-fn error-msg test-fn err etc...] ;; validate! accepts mutliple events
[:click "Does nothing" #(or % true)]
;; Empty or not, the following must be valid ;; and checked while typing
[:keyup ;; onKeyUp "Name can only contain letters and numbers" #(< 0 (count (.. (str %) (match (js/RegExp. "^\\w+$"))))) "Name must be at least 3 chars long" #(<= 3 (count %)) "Name must not contain a space" #(not (.. (str %) (contains " ")))]) ;; Enforce a valid submission ;; submit button object id
(valid-submit! "submit-button"
;; error message label object id
"submit-error"
;; error message
"The form input is invalid!"
;; do on valid
(fn [] (.. js/document (write "Form is valid!"))))))

(set! (.. js/window -onload) init)

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to