/* ================================= ------------------------------------ EndGam - Gaming Magazine Template Version: 1.0 ------------------------------------ ====================================*/ 'use strict'; $(window).on('load', function() { /*------------------ Preloder --------------------*/ $(".loader").fadeOut(); $("#preloder").delay(400).fadeOut("slow"); // Login Form $('#username').on('keypress', function (event) { var regex = new RegExp("^[a-zA-Z0-9]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } if (event.which == 32){ // console.log('Space Detected'); return false; } }); $('#username').on('keyup', function () { if ($(this).val().length <= 30 && $(this).val().length != 0) { $(this).removeClass('rejected'); $(this).addClass('confirmed'); $('#regbtn').attr('disabled', false); }else if ($(this).val().length == 0 ) { $(this).removeClass('confirmed'); $(this).addClass('rejected'); $('#regbtn').attr('disabled', true); }else{ $(this).removeClass('confirmed'); $(this).addClass('rejected'); $('#regbtn').attr('disabled', true); } }); $("#password").on("keyup",function(){ if($(this).val().length >= 8 && $(this).val().length <= 12 && $(this).val().length != 0){ if ($(this).val().match(/[A-z]/)) { if ($(this).val().match(/\d/)) { $(this).removeClass('rejected'); $(this).addClass('confirmed'); $('.pwd_note').hide(); $('#regbtn').attr('disabled', false); }else { $(this).removeClass('confirmed'); $(this).addClass('rejected'); $('.pwd_note').html('Must contain at least 1 number'); $('.pwd_note').show(); $('#regbtn').attr('disabled', true); } }else { $(this).removeClass('confirmed'); $(this).addClass('rejected'); $('.pwd_note').html('Must contain at least 1 letter'); $('.pwd_note').show(); $('#regbtn').attr('disabled', true); } }else{ $(this).removeClass('confirmed'); $(this).addClass('rejected'); $('.pwd_note').html('Must contain 8-12 digits'); $('.pwd_note').show(); $('#regbtn').attr('disabled', true); } }); $('#show_pwd').click(function(event) { $('#password').prop("type", "text"); $(this).hide(); $('#hide_pwd').show(); }); $('#hide_pwd').click(function(event) { $('#password').prop("type", "password"); $(this).hide(); $('#show_pwd').show(); }); $('#show_cpwd').click(function(event) { $('#confirm').prop("type", "text"); $(this).hide(); $('#hide_cpwd').show(); }); $('#hide_cpwd').click(function(event) { $('#confirm').prop("type", "password"); $(this).hide(); $('#show_cpwd').show(); }); $("#confirm").keyup(function() { var password = $("#password").val(); if (password.length == 0) { alert('Please enter password first'); } if ($(this).val() == password) { $(this).removeClass('rejected'); $(this).addClass('confirmed'); $('#regbtn').attr('disabled', false); }else { $(this).removeClass('confirmed'); $(this).addClass('rejected'); $('#regbtn').attr('disabled', true); } }); $('#firstname').on('keypress', function (event) { var regex = new RegExp("^[a-zA-Z ]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } }); $('#lastname').on('keypress', function (event) { var regex = new RegExp("^[a-zA-Z ]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } }); $('#phone').on('keypress', function (event) { var regex = new RegExp("^[0-9]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } }); // login form $('#login_user').on('keypress', function (event) { var regex = new RegExp("^[a-zA-Z0-9]+$"); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } if (event.which == 32){ // console.log('Space Detected'); return false; } }); $('#show_lpwd').click(function(event) { $('#login_pwd').prop("type", "text"); $(this).hide(); $('#hide_lpwd').show(); }); $('#hide_lpwd').click(function(event) { $('#login_pwd').prop("type", "password"); $(this).hide(); $('#show_lpwd').show(); }); }); (function($) { /*------------------ Navigation --------------------*/ $('.primary-menu').slicknav({ appendTo:'.header-warp', closedSymbol: '', openedSymbol: '' }); /*------------------ Background Set --------------------*/ $('.set-bg').each(function() { var bg = $(this).data('setbg'); $(this).css('background-image', 'url(' + bg + ')'); }); /*------------------ Hero Slider --------------------*/ $('.hero-slider').owlCarousel({ loop: true, nav: true, dots: true, navText: ['', ''], mouseDrag: false, animateOut: 'fadeOut', animateIn: 'fadeIn', items: 1, //autoplay: true, autoplayTimeout: 10000, }); var dot = $('.hero-slider .owl-dot'); dot.each(function() { var index = $(this).index() + 1; if(index < 10){ $(this).html('0').append(index + '.'); }else{ $(this).html(index + '.'); } }); /*------------------ Video Popup --------------------*/ $('.video-popup').magnificPopup({ type: 'iframe' }); $('#stickySidebar').stickySidebar({ topSpacing: 60, bottomSpacing: 60 }); })(jQuery);