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> <tr>
<td><label for='new-account-username'>{{i18n user.username.title}}</label></td> <td><label for='new-account-username'>{{i18n user.username.title}}</label></td>
<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"}} &nbsp;{{view Discourse.InputTipView validationBinding="view.usernameValidation"}}
</td> </td>
</tr> </tr>

View File

@ -17,7 +17,7 @@
<div class="control-group"> <div class="control-group">
<label class="control-label">{{i18n user.username.title}}</label> <label class="control-label">{{i18n user.username.title}}</label>
<div class="controls"> <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>
<div class='instructions'> <div class='instructions'>
{{#if controller.taken}} {{#if controller.taken}}

View File

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

View File

@ -504,6 +504,7 @@ en:
global_mismatch: "Already registered. Try {{suggestion}}?" global_mismatch: "Already registered. Try {{suggestion}}?"
not_available: "Not available. Try {{suggestion}}?" not_available: "Not available. Try {{suggestion}}?"
too_short: "Your username is too short." too_short: "Your username is too short."
too_long: "Your username is too long."
checking: "Checking username availability..." checking: "Checking username availability..."
enter_email: 'Username found. Enter matching email.' enter_email: 'Username found. Enter matching email.'