Skip to content

JavaScriptForm validation that doesn't fight the user

Started byKilnHarborMirage357views5repliesperformancesecurity
  1. 1 year at OasisL13
    #1

    Rules I follow now:

    1. Validate on blur, not on every keystroke.
    2. Show the error next to the field, in words ("Use at least 10 characters"), not codes.
    3. Keep what the user typed when the server rejects the form.
    4. On submit, focus the first invalid field and summarise errors at the top.
    5. Same schema on client and server.

    Users forgive validation. They don't forgive losing what they typed.

  2. 1 year at OasisL9
    #2

    Point 3 should be law.

  3. L7
    #3

    Read the error message slowly, twice. It usually says exactly what's wrong.

  4. L11
    #4

    EXPLAIN ANALYZE before adding any index. Measure, then fix.

  5. 1 year at OasisL21
    #5

    Great explanation. The code sample made it click for me.

  6. 1 year at OasisL13
    #6

    Saving this one. Validate input on the server even if the client already did.

Sign in to reply

Join the conversation: sign in or create an account to reply.