diff --git a/app/models/account.rb b/app/models/account.rb index 9084ec618ce..28cbe09b5ef 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -96,6 +96,7 @@ class Account < ActiveRecord::Base time_zone_attribute :default_time_zone, default: "America/Denver" validates_locale :default_locale, :allow_nil => true + validates_length_of :name, :maximum => maximum_string_length, :allow_blank => true validate :account_chain_loop, :if => :parent_account_id_changed? validate :validate_auth_discovery_url diff --git a/public/javascripts/account_settings.js b/public/javascripts/account_settings.js index 21f8b078930..4d75cf7655c 100644 --- a/public/javascripts/account_settings.js +++ b/public/javascripts/account_settings.js @@ -17,6 +17,7 @@ define([ $(document).ready(function() { $("#account_settings").submit(function() { + var $this = $(this); $(".ip_filter .value").each(function() { $(this).removeAttr('name'); }).filter(":not(.blank)").each(function() { @@ -25,6 +26,19 @@ define([ $(this).attr('name', 'account[ip_filters][' + name + ']'); } }); + var validations = { + object_name: 'account', + required: ['name'], + property_validations: { + 'name': function(value){ + if (value && value.length > 255) { return I18n.t("account_name_too_long", "Account Name is too long")} + } + } + }; + var result = $this.validateForm(validations); + if(!result) { + return false; + } }); $(".datetime_field").datetime_field(); $("#add_notification_form textarea").editorBox().width('100%');