Use .val() not attr('value'), as that behaves differently in latest jQuery