Enforce max username length on client

This commit is contained in:
Neil Lalonde
2013-02-08 15:31:15 -05:00
parent 24cf672c7d
commit d1a04fa06a
4 changed files with 6 additions and 2 deletions

View File

@@ -30,7 +30,7 @@
<tr>
<td><label for='new-account-username'>{{i18n user.username.title}}</label></td>
<td>
{{view Ember.TextField valueBinding="view.accountUsername" id="new-account-username"}}
{{view Ember.TextField valueBinding="view.accountUsername" id="new-account-username" maxlength="15"}}
&nbsp;{{view Discourse.InputTipView validationBinding="view.usernameValidation"}}
</td>
</tr>

View File

@@ -17,7 +17,7 @@
<div class="control-group">
<label class="control-label">{{i18n user.username.title}}</label>
<div class="controls">
{{view Ember.TextField valueBinding="controller.newUsername" elementId="change_username" classNames="input-xxlarge"}}
{{view Ember.TextField valueBinding="controller.newUsername" elementId="change_username" classNames="input-xxlarge" maxlength="15"}}
</div>
<div class='instructions'>
{{#if controller.taken}}

View File

@@ -69,6 +69,9 @@ window.Discourse.CreateAccountView = window.Discourse.ModalBodyView.extend Disco
# If too short
return Discourse.InputValidation.create(failed: true, reason: Em.String.i18n('user.username.too_short')) if @get('accountUsername').length < 3
# If too long
return Discourse.InputValidation.create(failed: true, reason: Em.String.i18n('user.username.too_long')) if @get('accountUsername').length > 15
@checkUsernameAvailability()
# Let's check it out asynchronously