Hello everyone ! Here a question :D I have this code
function validateName(){
if ( name.val().length <= 4 ){
name.removeClass('valid');
nameInfo.removeClass('valid');
name.addClass('error');
nameInfo.addClass('error');
nameInfo.text (" You need to have more than 4 letters ");
state = false;
}else{
var uname = name.val();
$.post('validateuser.php' , {names:uname} , function(data){
if (data != 1){
name.removeClass('valid');
nameInfo.removeClass('valid');
name.addClass('error');
nameInfo.addClass('error');
nameInfo.text("This name is already registered!");
state = false;
}else{
name.removeClass('error');
nameInfo.removeClass('error');
name.addClass('valid');
nameInfo.addClass('valid');
nameInfo.text('Valid name');
state = true;
}
});
}
return state;
}
and this one
$("#send").click(function(){
if( validateName() == true ){
alert('works');
});
And it actually won't work .. Any suggestions?