PageRenderTime 32ms CodeModel.GetById 24ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/Account/account.js

#
JavaScript | 112 lines | 101 code | 11 blank | 0 comment | 30 complexity | 402e5fc0d206e79c96bbca04b881e68d MD5 | raw file
  1function ShowStatus(status, msg) {
  2    $("[id$='_AdminStatus']").removeClass("warning");
  3    $("[id$='_AdminStatus']").removeClass("success");
  4
  5    $("[id$='_AdminStatus']").addClass(status);
  6    $("[id$='_AdminStatus']").html(msg + '<a href="javascript:HideStatus()" style="width:20px;float:right">X</a>');
  7    $("[id$='_AdminStatus']").fadeIn(1000, function () { });
  8}
  9
 10function HideStatus() {
 11    $("[id$='AdminStatus']").fadeOut('slow', function () { });
 12}
 13
 14function Hide(element) {
 15    $("[id$='" + element + "']").fadeOut('slow', function () { });
 16    return false;
 17}
 18
 19function ValidatePasswordRetrieval() {
 20    if ($("[id$='txtUser']").val().length == 0) {
 21        ShowStatus('warning', accountResources.userNameIsRequired);
 22        return false;
 23    }
 24    return true;
 25}
 26
 27function ValidateLogin() {
 28    if ($("[id$='UserName']").val().length == 0) {
 29        ShowStatus('warning', accountResources.userNameIsRequired);
 30        return false;
 31    }
 32    if ($("[id$='Password']").val().length == 0) {
 33        ShowStatus('warning', accountResources.passwordIsRequried);
 34        return false;
 35    }
 36    return true;
 37}
 38
 39function ValidateChangePassword() {    
 40    if ($("[id$='CurrentPassword']").val().length == 0) {
 41        ShowStatus('warning', accountResources.oldPasswordIsRequired);
 42        return false;
 43    }
 44    if ($("[id$='NewPassword']").val().length == 0) {
 45        ShowStatus('warning', accountResources.newPasswordIsRequired);
 46        return false;
 47    }
 48    var minReq = $("[id$='_hdnPassLength']").val();
 49    var minPass = $("[id$='NewPassword']").val().length;
 50
 51    if (minPass < minReq) {
 52        ShowStatus('warning', 'Minimum password length is ' + minReq + ' characters');
 53        return false;
 54    }
 55    if ($("[id$='ConfirmNewPassword']").val().length == 0) {
 56        ShowStatus('warning', accountResources.confirmPasswordIsRequired);
 57        return false;
 58    }
 59    if ($("[id$='NewPassword']").val() != $("[id$='ConfirmNewPassword']").val()) {
 60        ShowStatus('warning', accountResources.newAndConfirmPasswordMismatch);
 61        return false;
 62    }   
 63    return true;
 64}
 65
 66function ValidateNewUser() {
 67    if ($("[id$='UserName']").val().length == 0) {
 68        ShowStatus('warning', accountResources.userNameIsRequired);
 69        return false;
 70    }
 71    if ($("[id$='Email']").val().length == 0) {
 72        ShowStatus('warning', accountResources.emailIsRequired);
 73        return false;
 74    }
 75    if (ValidateEmail($("[id$='Email']").val()) == false) {
 76        ShowStatus('warning', accountResources.emailIsInvalid);
 77        return false;
 78    }
 79    if ($("[id$='Password']").val().length == 0) {
 80        ShowStatus('warning', accountResources.passwordIsRequried);
 81        return false;
 82    }
 83    var minReq = $("[id$='_hdnPassLength']").val();
 84    var minPass = $("[id$='Password']").val().length;
 85
 86    if (minPass < minReq) {
 87        ShowStatus('warning', accountResources.minPassLengthInChars.replace('{0}', minReq));
 88        return false;
 89    }
 90    if ($("[id$='ConfirmPassword']").val().length == 0) {
 91        ShowStatus('warning', accountResources.confirmPasswordIsRequired);
 92        return false;
 93    }
 94    if ($("[id$='Password']").val() != $("[id$='ConfirmPassword']").val()) {
 95        ShowStatus('warning', accountResources.passwordAndConfirmPasswordIsMatch);
 96        return false;
 97    }
 98    return true;
 99}
100
101function ValidateNewBlog() {
102    if ($("[id$='UserName']").val().length == 0) {
103        ShowStatus('warning', accountResources.userNameIsRequired);
104        return false;
105    }
106    return true;
107}
108
109function ValidateEmail(email) {
110    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
111    return reg.test(email);
112}