Let\'s say I have a text field:
Username:
I made a Fiddle
You can use a statement as
$(document).ready(function(){
$("#form").submit(function(e) {
length = $("#username").val().length;
if((length > 2 && length < 5)) {
$("#output").html("correct, logging in");
} else {
$("#output").html("incorrect, must have 3 or 4 chars");
}
return (length > 2 && length < 5);
});
});
And HTML