From 5c81f355aeba4df5ea840540f302c2e55e1deddd Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 5 Aug 2014 23:09:17 -0700 Subject: Validate user edit form --- public/js/setup.coffee | 19 +++++++++++++++---- public/js/setup.js | 17 +++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'public') diff --git a/public/js/setup.coffee b/public/js/setup.coffee index 6d8d7445..4e1c6b8f 100644 --- a/public/js/setup.coffee +++ b/public/js/setup.coffee @@ -1,4 +1,5 @@ #= require jquery-1.8.2.min.js +#= require jqiery-ui.min.js #= require 2.5.3-crypto-sha256.js #= require jsbn.js #= require jsbn2.js @@ -38,11 +39,18 @@ $(-> ).change() - $('#address').change(-> + $('#title').blur(-> + if $(this).val() == '' + $(this).parent().addClass('has-error') + else + $(this).parent().removeClass('has-error') + ) + + $('#address').blur(-> if check_address($(this).val()) - $(this).css('color', 'black') + $(this).parent().removeClass('has-error') else - $(this).css('color', 'red') + $(this).parent().addClass('has-error') ) $('#confirm').blur(-> @@ -55,7 +63,10 @@ $(-> ) $('#setup').submit(-> - return false if $('.has-error').length() + $('.form-control').blur() + if $('.has-error').length > 0 + $('.has-error').effect('shake', 500) + return false ) if user diff --git a/public/js/setup.js b/public/js/setup.js index 357b908e..9552e715 100644 --- a/public/js/setup.js +++ b/public/js/setup.js @@ -35,11 +35,18 @@ return $("#symbol option[value='bitstamp']").attr('selected', 'selected'); } }).change(); - $('#address').change(function() { + $('#title').blur(function() { + if ($(this).val() === '') { + return $(this).parent().addClass('has-error'); + } else { + return $(this).parent().removeClass('has-error'); + } + }); + $('#address').blur(function() { if (check_address($(this).val())) { - return $(this).css('color', 'black'); + return $(this).parent().removeClass('has-error'); } else { - return $(this).css('color', 'red'); + return $(this).parent().addClass('has-error'); } }); $('#confirm').blur(function() { @@ -52,7 +59,9 @@ } }); $('#setup').submit(function() { - if ($('.has-error').length()) { + $('.form-control').blur(); + if ($('.has-error').length > 0) { + $('.has-error').effect('shake', 500); return false; } }); -- cgit v1.2.3