I have my jQuery up and running with the exception of one glitch.
I have a form that calls a processing script when the user clicks the submit button through the standard:
<form id="myForm" method="post" action="process.php">
And my jQ is:
// Check if e-mail address already registered
$(document).ready(function(){
$('#e1').focusout(username_check);
});
function username_check(){
var email = $('#e1').val();
if(email == "" || email.length < 4){
$('#tick').hide();
}else{
jQuery.ajax({
type: "POST",
url: "signup-check-avail.php",
data: 'email='+ email,
cache: false,
success: function(response){
if(response == 1){
$('#tick').hide();
$('#cross').fadeIn();
$('#myForm input[type=submit]').click(function(event){
event.preventDefault();
});
}else{
$('#cross').hide();
$('#tick').fadeIn();
}
}
});
}
}
The part I'm having trouble with, and I may have coded it wrong, not sure, is:
$('#myForm input[type=submit]').click(function(event){
event.preventDefault();
});
Basically if the check returns that the user exists, then trying to click on the submit button would fail and the process.php script would never be called. But right now, it still opens the URL.
What did I miss?