Legacy admin forms often mix plain HTML with jQuery validators. .val() reads and writes input values; for checkboxes and radios use .prop('checked') in jQuery 3+ (avoid stale .attr('checked') patterns).
Single source of truth
Before submit, gather values into a plain object, validate, then post—do not assume the server reads unchecked boxes jQuery skipped. Mirror how the PHP endpoint already behaves.
Multi-select and disabled fields
.val() on <select multiple> returns an array. Disabled inputs are excluded from .serialize()—enable temporarily if the API requires them.
Compared to Vue/React
Frameworks bind state to inputs. jQuery imperatively queries the DOM at submit time—document field names when refactoring.
Interview
- Q: val() vs text()?
A:val()for inputs;text()/html()for element content.
Self-check
- How do you read an email field in one line?
- Why snapshot values before Ajax?
Challenge
Read inputs
- Change email field and click Save.
- Terminal JSON matches field values.
Done when: terminal JSON reflects current inputs.
Tip: Checkbox/radio need .prop("checked") in older code—know whether legacy uses .attr incorrectly.
Interview prep
- How read a text input value?
$("#field").val()gets/sets value; combine with validation before legacy form posts.