aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--new-account.lisp52
1 files changed, 33 insertions, 19 deletions
diff --git a/new-account.lisp b/new-account.lisp
index ea265a7..653818a 100644
--- a/new-account.lisp
+++ b/new-account.lisp
@@ -2,24 +2,31 @@
(in-package :vampire)
+(defparameter +username-regex+
+ (ppcre:create-scanner "^[a-zA-Z0-9\_\\-!@#$^&*]{3,25}$"))
+
+
+
(defun new-accout-page (body)
(include-style body)
(with-clog-create body
- (div ()
- (section (:h2 :content "Create a new account"))
- (form ()
- (form-element (:text :bind invite))
- (span (:bind invite-status))
- (br ())
- (form-element (:text :bind name))
- (span (:bind name-status))
- (br ())
- (form-element (:password :bind pw))
- (br ())
- (form-element (:password :bind pw-confirm))
- (span (:bind pw-confirm-status))
- (br ())
- (button (:content "Make Account" :bind submit))))
+ (div (:class "row")
+ (div () (section (:h2 :content "Create a new account"))
+ (form (:bind new-user-form)
+ (form-element (:text :bind invite))
+ (span (:bind invite-status))
+ (br ())
+ (form-element (:text :bind name))
+ (span (:bind name-status))
+ (br ())
+ (form-element (:password :bind pw))
+ (br ())
+ (form-element (:password :bind pw-confirm))
+ (span (:bind pw-confirm-status))
+ (br ())
+ (button (:content "Make Account" :bind submit))))
+ (div (:bind name-help :hidden t)
+ (p (:content "3-25 characters, no spaces, numbers, letters, or !@#$^&*()_-"))))
(setf (place-holder invite) "Invite Code"
(place-holder name) "Name"
@@ -36,10 +43,18 @@
(set-on-blur
name
(thunk*
+ (let ((name (value name)))
(setf (text name-status)
- (if (user-with-name name)
- "Name Already Taken"
- "✔"))))
+ (cond
+ ((not (ppcre:all-matches +username-regex+ name))
+ (setf (visiblep name-help) t)
+ "Invalid Name.")
+ ((user-with-name name)
+ (setf (visiblep name-help) nil)
+ "Name Already Taken")
+ (t
+ (setf (visiblep name-help) nil)
+ "✔"))))))
(set-on-key-press
pw-confirm
@@ -49,7 +64,6 @@
"✔"
"Passwords Do Not Match"))))
-
(set-on-click
submit
(thunk*