summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMario "Kuroir" Ricalde <kuroir@gmail.com>2013-02-20 01:15:26 -0600
committerMario "Kuroir" Ricalde <kuroir@gmail.com>2013-02-20 01:15:26 -0600
commitcb0d2acf3cd0c6a8e07ef564ac906fe623673978 (patch)
treecc834baaa918fefba0f154734ffdd0146630c037 /app
parente702dcbd01feccadc3d8d070448597ed63bb642d (diff)
Immediate Feedback for Inputs that are Missing
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/forms.js.coffee11
-rw-r--r--app/assets/stylesheets/gemeinschaft-generic.css.scss5
2 files changed, 16 insertions, 0 deletions
diff --git a/app/assets/javascripts/forms.js.coffee b/app/assets/javascripts/forms.js.coffee
new file mode 100644
index 0000000..42b1c45
--- /dev/null
+++ b/app/assets/javascripts/forms.js.coffee
@@ -0,0 +1,11 @@
+# Simple Form Toggle for required fields
+$(document).ready ->
+ validate_fields = (obj)->
+ if ($(obj).val() == "")
+ $(obj).addClass "invalid"
+ else
+ $(obj).removeClass "invalid"
+
+ sel = "input.required, textarea.required"
+ $(sel).each (i, e)-> validate_fields(e)
+ $(sel).keyup -> validate_fields(this)
diff --git a/app/assets/stylesheets/gemeinschaft-generic.css.scss b/app/assets/stylesheets/gemeinschaft-generic.css.scss
index 7077c87..9448b84 100644
--- a/app/assets/stylesheets/gemeinschaft-generic.css.scss
+++ b/app/assets/stylesheets/gemeinschaft-generic.css.scss
@@ -32,6 +32,11 @@ input, textarea, .uneditable-input {
width: 96%;
}
}
+input, textarea {
+ &.invalid {
+ box-shadow: inset -9px 0px 0px rgb(255, 219, 219), inset -14px 0px 0px rgb(255, 245, 245) !important;
+ }
+}
select {
width: 520px;