<div class="login_page">
	<div class="login-page">
		<div class="login-form">
			<form action="{{LINK reset-password/{{CODE}}}}" method="POST">
				<h4>{{LANG reset_password}}</h4>
				<div class="errors form-group errors_alert">{{ERRORS}}</div>
				<div class="errors success form-group">{{SUCCESS}}</div>
				<div class="pp_mat_input">
					<input type="password" name="password" id="password" placeholder="{{LANG password}}" required value="" autofocus>
					<label for="password">{{LANG password}}</label>
					<?php if ($pt->config->password_complexity_system == 1) { ?>
					<ul class="list-unstyled helper-text">
						<li class="length">{{LANG least_characters}}</li>
						<li class="lowercase">{{LANG contain_lowercase}}</li>
						<li class="uppercase">{{LANG contain_uppercase}}</li>
						<li class="special">{{LANG number_special}}</li>
					</ul>
					<input type="hidden" id="can_submit" value="0">
				<?php } ?>
				</div>
				<div class="pp_mat_input">
					<input type="password" name="re-password" id="re-password" placeholder="{{LANG confirm_password}}" required value="">
					<label for="re-password">{{LANG confirm_password}}</label>
				</div>
				<div class="login_signup_combo">
					<input type="submit" class="btn btn-main button" value="{{LANG change_password}}">
				</div>
				<hr>
				<div class="signup__">
					{{LANG already_have_account}} <a class="dec" href="{{LINK login}}">{{LANG login_}}</a>
				</div>
			</form>
		</div>    
	</div>
</div>
<script>
<?php if ($pt->config->password_complexity_system == 1) { ?>

(function(){
	$('.login-form form').submit(function( event ) {
		if ($('#can_submit').val() == 0) {
			event.preventDefault();
		  <?php if ($pt->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')) {
	    		$('#can_submit').val(1);
	    		$(this).submit();
	    	}
	    	else{
	    		$('.errors_alert').html("{{LANG complexity_requirements}}");
	    		return false;
	    	}
	      <?php } ?>
		}
	});
	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('#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
	function CheckCPassword() {
		$('.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');
	    }
	}
  password.addEventListener('keyup', CheckCPassword);
  password.addEventListener('input', CheckCPassword);
	
	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 } ?>
$(function() {
	$('.button').on('click', function () {
		if ($('#password').val() && $('#re-password').val()) {
			$(this).val("{{LANG please_wait}}");
		}
	});
});
</script>