110
/* Password validation */
111
var acceptedNewPwd = false;
112
var acceptedRepeatedPwd = false;
114
function emptyField(inputId){
115
var id = document.getElementById(inputId);
116
if(id.value.match(/^\s*$/)){
122
/* Checks input field for invalid characters */
123
function pwdValidCharacters(inputId){
124
var id = document.getElementById(inputId);
125
if(id.value.match(/^[A-Öa-ö0-9 _]*[A-Öa-ö0-9][A-Öa-ö0-9 _]*$/)){
131
/* Checks input field for minimum amount of characters(6) */
132
function pwdMininumValue(inputId){
133
var id = document.getElementById(inputId);
134
if(id.value.length > 5){
140
/* Checks if newPwd and repeatPwd are the same */
142
var firstPwd = document.getElementById("newPwd").value;
143
var secondPwd = document.getElementById("repeatPwd").value;
144
if(firstPwd == secondPwd){
150
function validNewPwd(){
151
var empty = emptyField("newPwd");
152
var validchar = pwdValidCharacters("newPwd");
153
var minimumchar = pwdMininumValue("newPwd");
155
if (empty==false && validchar==true && minimumchar==true){
156
document.getElementById("newPwd").className="Valid";
157
$('.errorMessage[name="newPwd"]').animate({opacity:0}, 0);
160
else if(empty==true){
161
acceptedNewPwd=false;
162
document.getElementById("newPwd").className="";
163
$('.errorMessage[name="newPwd"]').animate({opacity:0}, 0);
165
else if(empty==false && validchar==false || minimumchar==false){
166
document.getElementById("newPwd").className="notValid";
167
$('.errorMessage[name="newPwd"]').animate({opacity:1}, 0);
168
acceptedNewPwd=false;
172
function validRepeatedPwd(){
173
var empty = emptyField("repeatPwd");
174
var match = pwdMatch("repeatPwd");
178
document.getElementById("repeatPwd").className="";
179
$('.errorMessage[name="repeatPwd"]').animate({opacity:0}, 0);
180
acceptedRepeatedPwd=false;
182
else if(empty==false && match==false){
183
document.getElementById("repeatPwd").className="notValid";
184
$('.errorMessage[name="repeatPwd"]').animate({opacity:1}, 0);
185
acceptedRepeatedPwd=false;
187
else if(empty==false && match==true){
188
document.getElementById("repeatPwd").className="Valid";
189
$('.errorMessage[name="repeatPwd"]').animate({opacity:0}, 0);
190
acceptedRepeatedPwd=true;
194
document.getElementById("repeatPwd").className="";
198
/* baseURL skickas med som parameter */
199
function confirm(baseURL){
200
if(acceptedNewPwd && acceptedRepeatedPwd){
204
alert("WRONG WRONG WRONG!! FILL OUT THE FORM AGAIN YOU FKIN PIECE OF SHIT!");
209
function changePwd(baseURL)
211
var currentPwd = document.getElementById("currentPwd").value;
212
var newPwd = document.getElementById("newPwd").value;
213
var hintPwd = document.getElementById("hintPwd").value;
217
url: baseURL+'ajax/pwdchange',
219
currentPwd : currentPwd,
223
success: function(result){
224
var resultObject = JSON.parse(result);
225
if(resultObject.status==true){
226
alert('Password change is successful!');
227
$('#formContainer').fadeOut(300);
228
$('#passwordChanger').fadeOut(300);
229
$('body *').animate({
231
$('#changePassword')[0].reset();
234
alert('Wrong password!');
b'\\ No newline at end of file'