{"record":{"id":"42b8d77b848dc89b","repo":"sveltejs/kit","slug":"is-used-to-collect-all-formdata-validation-iss","errorCode":null,"errorMessage":"`$` is used to collect all FormData validation issues and cannot be used as the `name` of a form control","messagePattern":"`\\$` is used to collect all FormData validation issues and cannot be used as the `name` of a form control","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/client/remote-functions/form.svelte.js","lineNumber":832,"sourceCode":"/**\n * Shallow clone an element, so that we can access e.g. `form.action` without worrying\n * that someone has added an `<input name=\"action\">` (https://github.com/sveltejs/kit/issues/7593)\n * @template {HTMLElement} T\n * @param {T} element\n * @returns {T}\n */\nfunction clone(element) {\n\treturn /** @type {T} */ (HTMLElement.prototype.cloneNode.call(element));\n}\n\n/**\n * @param {FormData} form_data\n * @param {string} enctype\n */\nfunction validate_form_data(form_data, enctype) {\n\tfor (const key of form_data.keys()) {\n\t\tif (/^\\$[.[]?/.test(key)) {\n\t\t\tthrow new Error(\n\t\t\t\t'`$` is used to collect all FormData validation issues and cannot be used as the `name` of a form control'\n\t\t\t);\n\t\t}\n\t}\n\n\tif (enctype !== 'multipart/form-data') {\n\t\tfor (const value of form_data.values()) {\n\t\t\tif (value instanceof File) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Your form contains <input type=\"file\"> fields, but is missing the necessary `enctype=\"multipart/form-data\"` attribute. This will lead to inconsistent behavior between enhanced and native forms. For more details, see https://github.com/sveltejs/kit/issues/9819.'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":814,"sourceCodeEnd":848,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/client/remote-functions/form.svelte.js#L814-L848","documentation":"SvelteKit reserves form control names starting with $ (and $., $[) for collecting all FormData validation issues in one place. Using such a name would collide with that internal mechanism, so validate_form_data throws when any FormData key matches /^\\$[.[]?/.","triggerScenarios":"Submitting a remote form containing a control whose name attribute starts with $, such as name=\"$search\" or name=\"$.filter\", producing a matching FormData key.","commonSituations":"Naming fields after framework state conventions ($prefixed store-like names); generating names dynamically with a $ prefix; migrating forms from libraries where $ names were meaningful.","solutions":["Rename the control so its name does not start with $ (e.g. $search -> search)","If a $ prefix is required by an external API, transform the FormData in the remote function after removal of the prefix on the client","Adjust server-side expectations to accept the unprefixed name"],"exampleFix":"// before\n<input name=\"$query\" />\n// after\n<input name=\"query\" />","handlingStrategy":"validation","validationCode":"const RESERVED = /^\\$[.[]?/;\nfunction assertNoReservedNames(form) {\n  for (const el of form.elements) {\n    if (el.name && RESERVED.test(el.name)) throw new Error(`reserved name: ${el.name}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never start form control names with $","Lint codegen/templates for $-prefixed name attributes","Document reserved names for the team"],"tags":["formdata","validation","remote-forms","reserved-name"],"backgroundTag":"reserved-form-field-name","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}