Input value Property vs Attribute Desync
Quick summary
You read getAttribute('value') after the user typed — it returns the initial default, not the current input.
Why this happens
Reading getAttribute('value') instead of the .value property
Setting setAttribute('value', x) which does not update the current value in some browsers
Confusing the default-value attribute with the live value property
Minimal example
const input = document.querySelector('input');
input.value = 'typed';
console.log(input.getAttribute('value')); // old default, not 'typed'const input = document.querySelector('input');
input.value = 'typed';
console.log(input.value); // 'typed' — current contentgetAttribute('value') returns the default from the HTML, not the current content. The .value property always reflects what the user sees and typed.
How to diagnose
Compare element.getAttribute('value') with element.value after user input
Check whether code reads the attribute or the property
Use element.value for the current content in all cases
How to fix
Always read element.value for the current input content
Set element.value = x to update the displayed value
Use setAttribute only for the initial default value
How to prevent
Always use the .value property for input content, never getAttribute
Remember: attribute = default, property = current