-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathldap.jade
102 lines (96 loc) · 4.84 KB
/
ldap.jade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
extends layout
//http://www.blog.btbw.pl/java-script/node-js-express-jade-and-static-resource/
//http://1000hz.github.io/bootstrap-validator/
//form(method='POST', action='/ldap/change/password', data-toggle='validator', role='form'
block content
div.container
h1= title
p Welcome, please fill out the form:
form(id='enableForm', method='POST', action='/ldap/change/password', data-toggle='validator', role='form').form-horizontal
.form-group
label.col-xs-3.control-label LDAP-Username:
.col-xs-5
input.form-control(type='text', name='userName')
.form-group
label.col-xs-3.control-label Old password
.col-xs-5
input.form-control(type='password', name='oldPassword')
.form-group
label.col-xs-3.control-label New password
.col-xs-5
input.form-control(type='password', name='password')
.form-group
label.col-xs-3.control-label Confirm password
.col-xs-5
input.form-control(type='password', name='confirmPassword')
.form-group
.col-xs-5.col-xs-offset-3
button.btn.btn-default(type='submit') Change password
script.
$(document).ready(function () {
$('#enableForm')
.formValidation({
framework: 'bootstrap',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
userName: {
validators: {
notEmpty: {
message: 'The full name is required and cannot be empty'
}
}
},
oldPassword: {
enabled: true,
validators: {
notEmpty: {
message: 'The old password is required and cannot be empty'
}
}
}, password: {
enabled: true,
validators: {
notEmpty: {
message: 'The password is required and cannot be empty'
},
different: {
field: 'oldPassword',
message: 'Please provide a new password.'
}
}
},
confirmPassword: {
enabled: true,
validators: {
notEmpty: {
message: 'The confirm password is required and cannot be empty'
},
identical: {
field: 'password',
message: 'The password and its confirm must be the same'
},
different: {
field: 'oldPassword',
message: 'Please provide a new password.'
}
}
}
}
})
// Enable the password/confirm password validators if the password is not empty
.on('keyup', '[name="password"]', function () {
var isEmpty = $(this).val() == '';
('#enableForm')
.formValidation('enableFieldValidators', 'password', !isEmpty)
.formValidation('enableFieldValidators', 'confirmPassword', !isEmpty);
// Revalidate the field when user start typing in the password field
if ($(this).val().length == 1) {
$('#enableForm').formValidation('validateField', 'password')
.formValidation('validateField', 'confirmPassword');
}
});
});