You are not attaching the keyup event handlers until the submit event occurs. At that point the user has finished typing in all the fields.
Move the calls to $(...).keyup(...)
back to the dom ready event. You actually need one additional event handler to check user input:
$(document)
.ready(function(){
$('input[name=subdomain]').keyup(subdomain_check);
$('input[name=password]').keyup(password_strenght);
$('input[name=c_password]').keyup(password_check);
$('input[name=email]').keyup(email_check);
})
.submit(function(e) {
// validate input
// if invalid, show error message and call e.preventDefault();
});
The general user workflow is:
- The
domready
event in jQuery is invoked, attach the keyup event handlers - The user types in the form fields, triggering the keyup handlers
- The user submits the form, triggering the submit handler
- The submit handler validates the form input, and if invalid, shows the user an error message and prevents the submit event from continuing.