var backoffice = false; $(document).ready(function () { checkIfFormIsSubmitted(); if ($('div.controlBorder').length > 0) { $('body').addClass('backoffice'); backoffice = true; } keepAlive(); capsLockCheck(); }); function keepAlive() { //call callKeepAlive every 5 minutes if (useKeepAlive) { setInterval("callKeepAlive()", 5000 * 60); } } function callKeepAlive() { $.ajax({ type: "GET", url: "/handlers/keepalive.ashx" }); } //CMS-282 - Wouter Dirks - 06-10-2010 function checkIfFormIsSubmitted() { $('form').submit(function () { if ($('form').attr("isSubmitted")) { return false; } //CMS-441 - Wouter Dirks - 14-10-2010 - Page_IsValid is sometimes undefined if (typeof(Page_IsValid) != "undefined" && Page_IsValid) { $('form').attr("isSubmitted", true); } }); } function capsLockCheck() { // Caps lock check if ($('.capsLockMessage').length > 0 && $('input[type="password"]').length > 0) { $('input[type="password"]').focus(function () { $(this).keypress(function (e) { e = e || window.event; // We need alphabetic characters to make a match. var character = String.fromCharCode(e.keyCode | e.which); if (character.toUpperCase() === character.toLowerCase()) { return; } // SHIFT doesn't usually give us a lowercase character. Check for this // and for when we get a lowercase character when SHIFT is enabled. if ((e.shiftKey && character.toLowerCase() === character) || (!e.shiftKey && character.toUpperCase() === character)) { $(this).parents('div.customForm').find('.capsLockMessage').show(); } else { $(this).parents('div.customForm').find('.capsLockMessage').hide(); } }); }); } } function passwordStrength(password, resultClientId, score0, score1, score2, score3, score4) { var desc = new Array(); desc[0] = score0; desc[1] = score1; desc[2] = score2; desc[3] = score3; desc[4] = score4; var score = 0; if (password.match(/[a-z]/)) score++; if (password.match(/[A-Z]/)) score++; if (password.match(/\d+/)) score++; if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) score++; document.getElementById(resultClientId).innerHTML = desc[score]; //set the color if (score == 0) { document.getElementById(resultClientId).style.color="#465865"; } if (score == 1) { document.getElementById(resultClientId).style.color="#ff0000"; } if (score == 2) { document.getElementById(resultClientId).style.color="#ff6600"; } if (score == 3) { document.getElementById(resultClientId).style.color="#8ea300"; } if (score == 4) { document.getElementById(resultClientId).style.color="#23a300"; } }