<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/SunMaster.Master" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="SUNWEB.ChangePassword" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script language="javascript" type="text/javascript">

    function checkNumber(evt) {
        evt = (evt) ? evt : window.event
        var charCode = (evt.which) ? evt.which : evt.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            status = "This field accepts numbers only."
            return false
        }
        status = ""
        return true
    }

    function validate() {

        if (document.getElementById("<%=txtOldPassword.ClientID %>").value == "") {
            alert("Enter Old Password");
            document.getElementById("<%=txtOldPassword.ClientID %>").focus();
            return false;
        }

        if (document.getElementById("<%=txtNewPassword.ClientID %>").value == "") {
            alert("Enter New Password");
            document.getElementById("<%=txtNewPassword.ClientID %>").focus();
            return false;
        }

        if (document.getElementById("<%=txtRepeatPassword.ClientID %>").value == "") {
            alert("Enter Repeat Password");
            document.getElementById("<%=txtRepeatPassword.ClientID %>").focus();
            return false;
        }


    }
        
   </script>

 <script language="javascript" type="text/javascript">
     function passwordChanged() {
         var strength = document.getElementById('strength');
         var strongRegex = new RegExp("^(?=.{14,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
         var mediumRegex = new RegExp("^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
         var enoughRegex = new RegExp("(?=.{8,}).*", "g");
         var pwd = document.getElementById("txtNewPassword");
         if (pwd.value.length == 0) {
             strength.innerHTML = 'Type Password';
         } else if (false == enoughRegex.test(pwd.value)) {
             strength.innerHTML = 'More Characters';
         } else if (strongRegex.test(pwd.value)) {
             strength.innerHTML = '<span style="color:green">Strong!</span>';
         } else if (mediumRegex.test(pwd.value)) {
             strength.innerHTML = '<span style="color:orange">Medium!</span>';
         } else {
             strength.innerHTML = '<span style="color:red">Weak!</span>';
         }
     }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
                        <br /><br /><br />

                       <div class="row">
                        <!-- ============================================================== -->
                        <!-- basic form -->
                        <!-- ============================================================== -->
                        <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-12">
                            <div class="card">
                                <h5 class="card-header">Change Password </h5>
                                <div class="card-body">
                                    <form action="#" id="basicform" data-parsley-validate="">
                                    <br />
                                        <div class="form-group">
                                            <label for="inputUserName">Old Password </label>
                                            <asp:TextBox ID="txtOldPassword" runat="server" TextMode="Password" autocomplete="off" class="form-control"></asp:TextBox>
                                        </div>
                    
                                        <div class="form-group">
                                            <label for="inputPassword">Password</label>
                                            <asp:TextBox ID="txtNewPassword" runat="server" TextMode="Password" autocomplete="off"  class="form-control">
                                               </asp:TextBox>
                                           
                                        </div>
                                        <div class="form-group">
                                            <label for="inputRepeatPassword">Repeat Password</label>
                                            <asp:TextBox ID="txtRepeatPassword" runat="server" TextMode="Password" autocomplete="off"  class="form-control"></asp:TextBox>
                                        </div>
                                        <div class="row">
                                           &nbsp; &nbsp; &nbsp;<asp:Button ID="btnSave" runat="server" Text="Save" 
                                                class="btn btn-space btn-primary" onclick="btnSave_Click" OnClientClick="return validate()" />
                                        </div>
                                        <div>
                                        
                                           <asp:RegularExpressionValidator ID="Regex5" runat="server" ControlToValidate="txtNewPassword"
                                                ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,12}"
                                                ErrorMessage="<BR>Password must contain:<br> Minimum 8 and Maximum 12 characters<BR>Atleast 1 UpperCase Alphabet,<BR> 1 LowerCase Alphabet, <BR>1 Number and 1 Special Character"
                                                ForeColor="Red" />

                                          <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtRepeatPassword"
                                                ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,12}"
                                                ErrorMessage="<BR>Password must contain: <br>Minimum 8 and Maximum 12 characters<br> atleast 1 UpperCase Alphabet,<br> 1 LowerCase Alphabet,<br> 1 Number and 1 Special Character"
                                                ForeColor="Red" />
                                             <div class="form-group"> 
                                             <label for="inputRepeatPassword" style="color:Blue"> ** You should change the Default Password with Strong Password **</label>                                           
                                             <label for="inputRepeatPassword" style="color:Blue"> ** Your Password should contains 1 Uppercase,1 Alphabet </label>
                                             <label for="inputRepeatPassword" style="color:Blue">  1 Lowercase,1 Number,1 Special Character ** </label>                                           
                                            </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                     
                    </div>

                    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</asp:Content>
