Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Added validation to forgot password form #34

Merged
merged 2 commits into from Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
<form ng-submit="vm.submit()" class="ForgotPassword-form">
<form ng-submit="vm.submit()" class="ForgotPassword-form" name="vm.forgotPasswordForm" novalidate>
<div class="callout callout-danger" ng-if="vm.errorTrigger">
<h4>Error:</h4>
<p>Please check your email and try again.</p>
</div>
<div class="form-group has-feedback">
<input type="email" class="form-control" placeholder="Please enter your email address" ng-model="vm.email">
<div class="form-group has-feedback" ng-class="{ 'has-error': vm.forgotPasswordForm.email.$invalid && ( vm.formSubmitted || vm.forgotPasswordForm.email.$touched) }">
<input type="email" class="form-control" placeholder="Please enter your email address"
name="email"
ng-model="vm.email"
ng-required="true"
ng-pattern="/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
<p ng-show="vm.forgotPasswordForm.email.$error.email && ( vm.formSubmitted || vm.forgotPasswordForm.email.$touched)" class="help-block">This is not a valid email</p>
<p ng-show="vm.forgotPasswordForm.email.$error.required && ( vm.formSubmitted || vm.forgotPasswordForm.email.$touched)" class="help-block">Email is required.</p>
</div>
<div class="row">
<div class="col-xs-8">
</div>
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Submit</button>
<div class="col-xs-12">
<button type="submit" class="btn btn-primary btn-block btn-flat">
Submit
</button>
</div>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ForgotPasswordController {

this.API = API
this.$state = $state
this.errorTrigger = false
this.formSubmitted = false
}

$onInit () {
Expand All @@ -17,7 +17,7 @@ class ForgotPasswordController {
}).then(() => {
this.$state.go('login', { successMsg: `Please check your email for instructions on how to reset your password.` })
}, () => {
this.errorTrigger = true
this.formSubmitted = true
})
}
}
Expand Down
21 changes: 18 additions & 3 deletions angular/app/pages/forgot-password/forgot-password.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,23 @@
<a ui-sref="login"><b>Admin</b>LTE</a>
</div>
<div class="login-box-body">
<h3>Forgot your password?</h3>
<forgot-password></forgot-password>
<a ui-sref="login">Back to Login Page</a>
<div class="row">
<div class="col-xs-12">
<div class="text-center">
<h3>Forgot your password?</h3>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<forgot-password></forgot-password>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-12">
<a ui-sref="login">Back to Login Page</a>
</div>
</div>
</div>
</div>