From cb0d2acf3cd0c6a8e07ef564ac906fe623673978 Mon Sep 17 00:00:00 2001 From: "Mario \"Kuroir\" Ricalde" Date: Wed, 20 Feb 2013 01:15:26 -0600 Subject: Immediate Feedback for Inputs that are Missing --- app/assets/javascripts/forms.js.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 app/assets/javascripts/forms.js.coffee (limited to 'app/assets/javascripts/forms.js.coffee') 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) -- cgit v1.2.3