AIRAVATA-2156 Client-side validate required SSH key description
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/83a83731 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/83a83731 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/83a83731 Branch: refs/heads/develop Commit: 83a83731defcaf39013c335962ef933c75ab7991 Parents: 7c14035 Author: Marcus Christie <[email protected]> Authored: Thu Oct 27 10:00:36 2016 -0400 Committer: Marcus Christie <[email protected]> Committed: Thu Oct 27 10:00:36 2016 -0400 ---------------------------------------------------------------------- app/views/account/credential-store.blade.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/83a83731/app/views/account/credential-store.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/credential-store.blade.php b/app/views/account/credential-store.blade.php index 9c9bca3..6908844 100644 --- a/app/views/account/credential-store.blade.php +++ b/app/views/account/credential-store.blade.php @@ -38,11 +38,11 @@ {{ CommonUtilities::print_error_message($error) }} @endforeach @endif - <form class="form-inline" action="{{ URL::to('/') }}/account/add-credential" method="post"> - <div class="form-group"> - <label for="defaultToken" class="sr-only">Description for new SSH key</label> + <form id="add-credential" class="form-inline" action="{{ URL::to('/') }}/account/add-credential" method="post"> + <div id="credential-description-form-group" class="form-group"> + <label for="credential-description" class="sr-only">Description for new SSH key</label> <input type="text" id="credential-description" name="credential-description" - class="form-control" placeholder="Description" /> + class="form-control" placeholder="Description" required/> </div> <button type="submit" class="btn btn-default">Add</button> </form> @@ -115,5 +115,16 @@ $('.delete-credential').on('click', function(){ $("#delete-credential-modal .credential-description").text(credentialDescription); $("#delete-credential-modal").modal("show"); }); + +$('#credential-description').on('invalid', function(event){ + $('#credential-description-form-group').addClass('has-error'); +}); +$('#credential-description').on('keyup input change', function(event){ + if (this.checkValidity) { + var valid = this.checkValidity(); + this.setCustomValidity("Please provide a description"); + $('#credential-description-form-group').toggleClass('has-error', !valid); + } +}); </script> @stop \ No newline at end of file
