Get text in the input field and check if it is equal to its value attribute?

advertisements

I have this when the page loads

<input class="input" id="accountNameUsernameForm_name" name="profile[real_name]" size="30" type="text" value="George">

When a submit trigger is pressed I want to check if the current text in the input field is the same as it's value attribute?

if ( $('.input').val() != $('.input').attr('value') ) {
        $(this).addClass('formLoading');
}

However the problem is, val() and the attr('value') are always the same. What function retrieves the current text that is in the input right now without looking at its value attribute?

thank you

btw. it doesn't work with text()!


// save the default value on page load
var defaultUsername = $('.input').val();

// on submit, compare
if ( $('.input').val() != defaultUsername ) {
        $(this).addClass('formLoading');
}