Jquery and input elements of type password and email

Jquery and input elements of type password and email

Hello, I have a question regarding verification of input element values. Currently, I set the value of the designated inputs (both email and password) for automatic login. I want to verify the content of each element before I automatically submit the form. So the code I have in place is like this...

// Set value
var u = $('control-id');
u.focus();
u.val(' myemail@domain.com');

// Verify value
if (u.val() !== ' myemail@domain.com') {
console.log('FAIL  val = ' +  u.val());
}

So most of the time I will get "undefined" back for the value. However, that being said, other sites for our application it will work as expected. It is necessary I verify the results before submit. Does anybody have any thoughts or suggestions?

Thanks,
Tom