diff options
| author | Adam Soltys <[email protected]> | 2014-08-05 23:09:17 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2014-08-05 23:09:17 -0700 |
| commit | 5c81f355aeba4df5ea840540f302c2e55e1deddd (patch) | |
| tree | 64fb003b99e3e4b790c1b4d47fd50962c630b08a /public/js | |
| parent | 7ed32d3ab9992797c5caed93d7394479a7810105 (diff) | |
| download | coinos-server-5c81f355aeba4df5ea840540f302c2e55e1deddd.tar.gz coinos-server-5c81f355aeba4df5ea840540f302c2e55e1deddd.zip | |
Validate user edit form
Diffstat (limited to 'public/js')
| -rw-r--r-- | public/js/setup.coffee | 19 | ||||
| -rw-r--r-- | public/js/setup.js | 17 |
2 files changed, 28 insertions, 8 deletions
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; } }); |
