I am trying to check if the user has clicked in an input with in a given time 3 seconds, if not hide the panel.
But my checkInput is not working. If I put it in the main jQuery if just shows for the 3 seconds and then disapears.
My Css is just display:none.
Any help would be good.
<div class="sign-up">
<h4>Login</h4>
<div class="sign-up-line">
<asp:Label ID="lbl_usr_name" runat="server" Text="User name" /><br />
<asp:TextBox ID="txt_usr_name" runat="server" CssClass="form-control" />
</div>
<div class="sign-up-line">
<asp:Label ID="lbl_password" runat="server" Text="Password" /><br />
<asp:TextBox ID="txt_password" runat="server" CssClass="form-control" TextMode="Password"/>
</div>
<div class="sign-up-text">
<p>Forgotten your password <a href="#">click here</a></p>
<p>Problems logging in <a href="#">click here</a></p>
</div>
</div>
var signUpPanel = $('.sign-up');
var userName = $('#txt_usr_name');
var password = $('#txt_password');
$('.sign-up-link').on('click', function () {
if (signUpPanel.is(":hidden")) {
userName.val('');
password.val('');
signUpPanel.slideDown('slow');
checkInput();
} else {
signUpPanel.hide();
}
});
function checkInput() {
//set timer
setTimeout(function () {
if (userName.val() && password.val()) {
signUpPanel.hide();
} else if (!userName.val() && !password.val()) {
signUpPanel.show();
}
}, 3000);
}
checkInput()function you are hiding the panel if there IS a username and password value. Surely you want it the other way round?