Jquery username check
- by Sergio
I'm using this Jquery function for available username check.
How can I fire this Jquery function only if the username field is greater of 5 characters?
Jquery looks like:
$(document).ready(function() {
$('#usernameLoading').hide();
$('#username').blur(function(){
$('#usernameLoading').show();
$.post("usercheck.php", {
un: $('#username').val()
}, function(response){
$('#usernameResult').fadeOut();
setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400);
});
return false;
});
});
function finishAjax(id, response) {
$('#usernameLoading').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
} //finishAjax
Can I use something like this and how:
var usr = $("#username").val();
if(usr.length >= 5)
{
}