Skip to content

Commit

Permalink
fix: added setAttribute on setInputElementValue (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
sahinvardar authored Nov 3, 2023
1 parent 1f88adb commit 4989a16
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zod-form-validation-html-example",
"version": "0.1.9",
"version": "0.1.10",
"description": "",
"main": "index.html",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react",
"version": "0.1.9",
"version": "0.1.10",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
2 changes: 1 addition & 1 deletion library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vardario/zod-form-validation",
"version": "0.1.9",
"version": "0.1.10",
"description": "",
"main": "dist/index.js",
"type": "module",
Expand Down
3 changes: 3 additions & 0 deletions library/src/form-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ function setSelectElementValue(selectElement: HTMLSelectElement, values: string[
function setInputElementValue(inputElement: HTMLInputElement, value: string) {
if (inputElement.type === 'checkbox' || inputElement.type === 'radio') {
inputElement.checked = inputElement.value === value.replace('true', 'on');
inputElement.setAttribute('checked', value.replace('true', 'on'));
} else {
inputElement.value = value;
inputElement.setAttribute('value', value);
}
}

Expand All @@ -45,6 +47,7 @@ export function setFormDataToForm(form: HTMLFormElement, formData: FormData) {
if (formInput.nodeName === 'TEXTAREA') {
const textareaElement = formInput as HTMLTextAreaElement;
textareaElement.value = values[0];
textareaElement.setAttribute('value', values[0]);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "root",
"version": "0.1.9",
"version": "0.1.10",
"license": "MIT",
"repository": {
"type": "git",
Expand Down

0 comments on commit 4989a16

Please sign in to comment.