Hey I have a login form that when you click on the input the label move up, after focus out it checks if there is text in the input and if have the label stays up if dont the label comes down.
My code is:
$(function () {
$('.loginForm .inputGroup input').focusout(function () {
var text_val = $(this).val();
if (text_val === "") {
$(this).removeClass('has-value');
} else {
$(this).addClass('has-value');
}
});
});
The problem is when I click on login and it gives an error like username does not exist I want to keep the username on the input but when I do it the label stays on top of the text on the input.
How can I check on load if have text or not on the input?
Images to help understand the situation:

JSFiddle: http://jsfiddle.net/16g7yhLf/
Cheers!