UX: Specify pattern and maxlength for 2FA input fields.

This commit is contained in:
Guo Xiang Tan 2018-02-26 18:28:47 +08:00
parent 7d7f6faf40
commit a9699da672
5 changed files with 16 additions and 4 deletions

View File

@ -46,6 +46,8 @@
</div> </div>
{{#second-factor-form}} {{#second-factor-form}}
{{text-field value=loginSecondFactor {{text-field value=loginSecondFactor
pattern='[0-9]{6}'
maxlength='6'
id="login-second-factor" id="login-second-factor"
autocorrect="off" autocorrect="off"
autocapitalize="off" autocapitalize="off"

View File

@ -34,7 +34,13 @@
</table> </table>
</div> </div>
{{#second-factor-form}} {{#second-factor-form}}
{{text-field value=loginSecondFactor id="login-second-factor" autocorrect="off" autocapitalize="off" autofocus="autofocus"}} {{text-field value=loginSecondFactor
pattern='[0-9]{6}'
maxlength='6'
id="login-second-factor"
autocorrect="off"
autocapitalize="off"
autofocus="autofocus"}}
{{/second-factor-form}} {{/second-factor-form}}
</form> </form>
{{/if}} {{/if}}

View File

@ -20,7 +20,9 @@
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
{{text-field value=second_factor_token {{text-field value=second_factor_token
id="second_factor_token" pattern='[0-9]{6}'
maxlength='6'
id="second-factor-token"
classNames="input-large" classNames="input-large"
autofocus="autofocus"}} autofocus="autofocus"}}
</div> </div>
@ -69,6 +71,8 @@
<div class="controls"> <div class="controls">
{{text-field value=second_factor_token {{text-field value=second_factor_token
pattern='[0-9]{6}'
maxlength='6'
id="second-factor-token" id="second-factor-token"
classNames="input-large" classNames="input-large"
autofocus="autofocus"}} autofocus="autofocus"}}

View File

@ -10,7 +10,7 @@
<%= form_tag(method: "post") do%> <%= form_tag(method: "post") do%>
<h2><%=t "login.second_factor_title" %></h2> <h2><%=t "login.second_factor_title" %></h2>
<%= label_tag(:second_factor_token, t("login.second_factor_description")) %> <%= label_tag(:second_factor_token, t("login.second_factor_description")) %>
<div><%= text_field_tag(:second_factor_token) %></div> <div><%= text_field_tag(:second_factor_token, pattern: '[0-9]{6}', maxlength: 6) %></div>
<%= submit_tag(t("submit"), class: "btn btn-large btn-primary") %> <%= submit_tag(t("submit"), class: "btn btn-large btn-primary") %>
<%end%> <%end%>
</div> </div>

View File

@ -10,7 +10,7 @@
<% if @second_factor_required %> <% if @second_factor_required %>
<%=form_tag({}, method: :put) do %> <%=form_tag({}, method: :put) do %>
<%= label_tag(:second_factor_token, t('login.second_factor_description')) %> <%= label_tag(:second_factor_token, t('login.second_factor_description')) %>
<%= text_field_tag(:second_factor_token, nil, autofocus: true) %><br><br> <%= text_field_tag(:second_factor_token, nil, autofocus: true, pattern: '[0-9]{6}', maxlength: 6) %><br><br>
<%= submit_tag t('submit')%> <%= submit_tag t('submit')%>
<% end %> <% end %>
<% end %> <% end %>