コードは次のとおりです。-ここで変数を宣言しました:
var first = $('#first');
var firstError = $('#firsterror'); // the errors are in span tags (if it matters)
// and so on...
first.blur(validateFirst);
last.blur(validateLast);
username.blur(validateUsername);
password.blur(validatePassword);
confpassword.blur(validateConfpassword);
month.blur(validateMonth);
day.blur(validateDay);
year.blur(validateYear);
gender.blur(validateGender);
$('#myForm').submit(function(){
if( validateFirst() & validateLast() & validateUsername() & validatePassword() & validateConfpassword() & validateMonth() & validateDay() & validateYear() & validateGender() ){
return true;
}else{
return false;
}
});
function validateFirst(){
if(first.val().length < 5){
first.addClass('error_input');
firstError.text('You left this empty!');
firstError.addClass('error');
return false;
}else{
first.removeClass('error_input');
firstError.text('');
return true;
}
};
// and so on... I would like the code to work as so: When an input recives focus the error should hide else the code should run exactly as it is.
ありがとうございました..