Ok, so I'm trying to make a new log in form form my site using jquery and classic ASP. As of right now I have a containing div in my document thats set to hidden, then when the user selects the login link the div will fade in overlaying the page with the form. If the user clicks submit, the page will POST and the div overlay is gone. I would really like it to be more smooth than that. So if the users clicks submit, jquery will use ajax or something to post it in the background to a db connect page and then get the response text from that asp displaying either a successful login or incorrect in the errors label.
I use classic asp on my site to fetch the form data on submit with the previous login. then that checks the DB to see if what was entered matches.
I would like to have jQuery handle all this and send the values through a query or other method in the background to the ASP page containing the DB connection so the page doesn't reload when submit is clicked.
I've looked a a hand full of examples and I can't seem to get them going right.
Heres a FIDDLE to look at with the working functions so far.
Any help would be greatly appreciated, Thanks in advance.
<table cellspacing="0" cellpadding="0" width="900" >
<tr>
<a href="index.asp" class="linkheader">Home</a> |
<a href="index1st.asp">1st</a> |
<a href="index2nd.asp">2nd</a> |
<a href="index3rd.asp">3rd</a> |
<a href="index4th.asp">4th</a> |
<a href='#' id='login' class='linkheader'>Log In</a></td>
</tr>
</table>
<!-- blur_login is transparent overlay. starts as hidden untill link is selected -->
<div id="blur_login">
<!-- show_login is container for login form -->
<div id="show_login">
<a class="OKclose" href="#" >[ Close ]</a>
<form method="" id="getin">
<p><label for="Username">Username</label><br />
<input name="Username" id="users" type="text" size="14" maxlength="14" autocomplete="off" tabindex="1"/>
</p>
<p><label for="last_name">Password</label><br />
<input name="last_name" type="password" size="14" maxlength="14" autocomplete="off" tabindex="2" /><br />
<label for="errors"></label>
</p>
<p><input type="submit" id="send" value="Log In →"></p>
</form>
</div>
</div>
$(document).ready(function() {
$(window).bind("resize", function(){
$("#blur_login").css("height", $(window).height());
$("#blur_logout").css("height", $(window).height());
});
//Adjust height of overlay to fill screen when page loads
$("#blur_login").css("height", $(document).height());
$('#login').click(function(a){
$("#blur_login").fadeIn();
// Page focus on fadein is the username input
$('#users').focus();
a.preventDefault;
return false;
});
$('#logout').click(function(b){
$("#blur_logout").fadeIn();
b.preventDefault;
return false;
});
$('#send').click(function(c){
//AJAX form submit here
});
// Functions for login form
var $submit = $("input[type=submit]"),
$inputs = $('input[type=text], input[type=password]');
// Checks if fields are empty, if so then disable loginbutton
function checkEmpty() {
return $inputs.filter(function() {
return !$.trim(this.value);
}).length === 0;
}
// Enables the submit button when characters have been entered in each field
$inputs.on('keyup blur', function() {
$submit.prop("disabled", !checkEmpty());
}).keyup(); // trigger any one
// When the close link is selected the window will fade out
$(".OKclose").click(function(d){
$("#blur_login").fadeOut();
d.preventDefault;
return false;
});
});