<?php echo Wo_LoadPage('welcome/welcome-header');?>
<div class="wrapper">
	<div class="container">
		<div class="row login forgot_pass">
			<div class="col-md-4"></div>
			<div class="col-md-4">
				<div class="sun_welcome_heading">
					<h1><?php echo $wo['lang']['reset_new_password_label']; ?></h1>
				</div>
				<form id="reset-form" class="small-padd" method="post">
					<div class="errors"></div>
					<div class="loading_cont">
						<div class="loading hidden"></div>
					</div>
					<div class="sun_input_holder">
						<div class="sun_input">
							<input name="password" type="password" id="new_password" placeholder="<?php echo $wo['lang']['new_password'];?>" autofocus/>
							<label for="new_password"><?php echo $wo['lang']['new_password']?></label>
							<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>
							<?php if ($wo['config']['password_complexity_system'] == 1) { ?>
								<ul class="helper-text">
									<li class="length"><?php echo $wo['lang']['least_characters']; ?></li>
									<li class="lowercase"><?php echo $wo['lang']['contain_lowercase']; ?></li>
									<li class="uppercase"><?php echo $wo['lang']['contain_uppercase']; ?></li>
									<li class="special"><?php echo $wo['lang']['number_special']; ?></li>
								</ul>
							<?php } ?>
						</div>
					</div>
					<input type="hidden" name="id" value="<?php echo $_GET['code'];?>">
					<div class="login_signup_combo">
						<div class="login__">
							<button type="submit" class="btn btn-main"><?php echo $wo['lang']['reset_password']?></button>
						</div>
						<div class="signup__">
						</div>
					</div>
				</form>
			</div>
			<div class="col-md-4"></div>
		</div>
	</div>
</div>

<div class="container"><?php echo Wo_LoadPage('footer/welcome');?></div>

<script>
var working = false;
var $this = $('#reset-form');
var $state = $this.find('.errors');
$(function() {
  $this.ajaxForm({
    url: Wo_Ajax_Requests_File() + '?f=reset_password',
    beforeSend: function() {
    	<?php if ($wo['config']['password_complexity_system'] == 1) { ?>
    		if ($('.helper-text .length').hasClass('valid') && $('.helper-text .lowercase').hasClass('valid') && $('.helper-text .uppercase').hasClass('valid') && $('.helper-text .special').hasClass('valid')) {
	    		working = true;
				$this.find('button').attr("disabled", true);
				$this.find('.loading').removeClass('hidden');
	    	}
	    	else{
	    		$state.html("<?php echo($wo['lang']['complexity_requirements']) ?>");
	    		return false;
	    	}

        <?php } else{ ?>
        	working = true;
			$this.find('button').attr("disabled", true);
			$this.find('.loading').removeClass('hidden');
        <?php } ?>
    },
    success: function(data) {
      if (data.status == 200 || data.status == 600) {
        $state.addClass('success');
        $state.html('<?php echo $wo['lang']['welcome_'] ?>');
		$this.find('.loading').addClass('hidden');
        setTimeout(function () {
         window.location.href = data.location;
        }, 1000);
      } else {
        $this.find('button').attr("disabled", false);
		$this.find('.loading').addClass('hidden');
        $state.html(data.errors);
      } 
      working = false;
    }
  });
});

<?php if ($wo['config']['password_complexity_system'] == 1) { ?>

(function(){
	var helperText = {
		charLength: document.querySelector('.helper-text .length'),
		lowercase: document.querySelector('.helper-text .lowercase'),
		uppercase: document.querySelector('.helper-text .uppercase'),
		special: document.querySelector('.helper-text .special')
	};
	var password = document.querySelector('#new_password');
	
	
	
	var pattern = {
		charLength: function() {
			if( password.value.length >= 6 ) {
				return true;
			}
		},
		lowercase: function() {
			var regex = /^(?=.*[a-z]).+$/; // Lowercase character pattern

			if( regex.test(password.value) ) {
				return true;
			}
		},
		uppercase: function() {
			var regex = /^(?=.*[A-Z]).+$/; // Uppercase character pattern

			if( regex.test(password.value) ) {
				return true;
			}
		},
		special: function() {
			var regex = /^(?=.*[0-9_\W]).+$/; // Special character or number pattern

			if( regex.test(password.value) ) {
				return true;
			}
		}   
	};
	
	// Listen for keyup action on password field
  password.addEventListener('keyup', function (){
  	    $('.helper-text').slideDown('slow', function() {
  	    	
  	    });
		// Check that password is a minimum of 8 characters
		patternTest( pattern.charLength(), helperText.charLength );
		
		// Check that password contains a lowercase letter		
		patternTest( pattern.lowercase(), helperText.lowercase );
		
		// Check that password contains an uppercase letter
		patternTest( pattern.uppercase(), helperText.uppercase );
		
		// Check that password contains a number or special character
		patternTest( pattern.special(), helperText.special );
    
    // Check that all requirements are fulfilled
    if( hasClass(helperText.charLength, 'valid') &&
			  hasClass(helperText.lowercase, 'valid') && 
			 	hasClass(helperText.uppercase, 'valid') && 
			  hasClass(helperText.special, 'valid')
		) {
			addClass(password.parentElement, 'valid');
    }
    else {
      removeClass(password.parentElement, 'valid');
    }
	});
	
	function patternTest(pattern, response) {
		if(pattern) {
      addClass(response, 'valid');
    }
    else {
      removeClass(response, 'valid');
    }
	}
	
	function addClass(el, className) {
		if (el.classList) {
			el.classList.add(className);
		}
		else {
			el.className += ' ' + className;
		}
	}
	
	function removeClass(el, className) {
		if (el.classList)
				el.classList.remove(className);
			else
				el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
	}
	
	function hasClass(el, className) {
		if (el.classList) {
			console.log(el.classList);
			return el.classList.contains(className);	
		}
		else {
			new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);	
		}
	}
	
})();
<?php } ?>
</script>
<style type="text/css">
	 .helper-text {
	    display: none;
	    margin-top: 6px;
	    font-size: 12px;
	    line-height: 22px;
	    color: #808080;
	  }
	  li.valid {
      color: #1fd34a;
    }
</style>