Improved form validation.
This commit is contained in:
parent
57d0b22e09
commit
87bd535ad5
4 changed files with 19 additions and 18 deletions
|
@ -623,10 +623,10 @@ class App.ControllerForm extends App.Controller
|
|||
|
||||
|
||||
@enable: (form) ->
|
||||
App.Log.log 'ControllerForm', 'notice', 'enable...', $(form).parent()
|
||||
$(form).parent().find('button').attr('disabled', false)
|
||||
$(form).parent().find('[type="submit"]').attr('disabled', false)
|
||||
$(form).parent().find('[type="reset"]').attr('disabled', false)
|
||||
App.Log.log 'ControllerForm', 'notice', 'enable...', $(form.target).parent()
|
||||
$(form.target).parent().find('button').attr('disabled', false)
|
||||
$(form.target).parent().find('[type="submit"]').attr('disabled', false)
|
||||
$(form.target).parent().find('[type="reset"]').attr('disabled', false)
|
||||
|
||||
@validate: (data) ->
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ class Index extends App.Controller
|
|||
|
||||
login: (e) ->
|
||||
e.preventDefault()
|
||||
@formDisable(e)
|
||||
params = @formParam(e.target)
|
||||
|
||||
# remember username
|
||||
|
|
|
@ -27,18 +27,18 @@ class Index extends App.Controller
|
|||
@html App.view('signup')()
|
||||
|
||||
new App.ControllerForm(
|
||||
el: @el.find('#form-signup'),
|
||||
model: App.User,
|
||||
required: 'signup',
|
||||
autofocus: true,
|
||||
el: @el.find('#form-signup')
|
||||
model: App.User
|
||||
required: 'signup'
|
||||
autofocus: true
|
||||
)
|
||||
|
||||
cancel: ->
|
||||
@navigate 'login'
|
||||
|
||||
submit: (e) ->
|
||||
@log 'submit'
|
||||
e.preventDefault()
|
||||
@formDisable(e)
|
||||
@params = @formParam(e.target)
|
||||
|
||||
# if no login is given, use emails as fallback
|
||||
|
@ -54,18 +54,18 @@ class Index extends App.Controller
|
|||
if errors
|
||||
@log 'error new', errors
|
||||
@formValidate( form: e.target, errors: errors )
|
||||
@formEnable(e)
|
||||
return false
|
||||
|
||||
# save user
|
||||
user.save(
|
||||
success: (r) =>
|
||||
App.Auth.login(
|
||||
data: {
|
||||
username: @params.login,
|
||||
password: @params.password,
|
||||
},
|
||||
data:
|
||||
username: @params.login
|
||||
password: @params.password
|
||||
success: @success
|
||||
error: @error,
|
||||
error: @error
|
||||
)
|
||||
# error: =>
|
||||
# @modalHide()
|
||||
|
@ -90,13 +90,13 @@ class Index extends App.Controller
|
|||
# add notify
|
||||
App.Event.trigger 'notify:removeall'
|
||||
App.Event.trigger 'notify', {
|
||||
type: 'warning',
|
||||
msg: 'Wrong Username and Password combination.',
|
||||
type: 'warning'
|
||||
msg: 'Wrong Username and Password combination.'
|
||||
}
|
||||
|
||||
# rerender login page
|
||||
@render(
|
||||
msg: 'Wrong Username and Password combination.',
|
||||
msg: 'Wrong Username and Password combination.'
|
||||
username: @username
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="row">
|
||||
<div class="span12">
|
||||
<p><%- @T( 'Sign in with' ) %></p>
|
||||
<form id="login" class="form-search">
|
||||
<form id="login" class="form-search" method="post">
|
||||
<input name="username" type="text" class="input span3" placeholder="<%- @Ti( 'Username or email' ) %>" value="<%= @item.username %>" autocapitalize="off"/>
|
||||
<input name="password" type="password" class="input span3" placeholder="<%- @Ti( 'Password' ) %>"/>
|
||||
<button class="btn btn-primary" type="submit"><%- @T( 'Sign in' ) %></button>
|
||||
|
|
Loading…
Reference in a new issue