diff --git a/src/Guestbooky/Guestbooky.API/DTOs/Messages/InsertMessage.cs b/src/Guestbooky/Guestbooky.API/DTOs/Messages/InsertMessage.cs index f116579..7a83f3e 100644 --- a/src/Guestbooky/Guestbooky.API/DTOs/Messages/InsertMessage.cs +++ b/src/Guestbooky/Guestbooky.API/DTOs/Messages/InsertMessage.cs @@ -17,6 +17,6 @@ public record InsertMessageRequestDto [JsonPropertyName("captchaResponse")] [Required(ErrorMessage = "The captcha challenge response is required")] - [StringLength(1024)] + [StringLength(2048)] public string CaptchaResponse { get; init; } } \ No newline at end of file diff --git a/src/input-example/example.html b/src/input-example/example.html index 0f62e4d..81b219d 100644 --- a/src/input-example/example.html +++ b/src/input-example/example.html @@ -133,22 +133,23 @@ document captchaResponse, }; - const response = await fetch(this.action, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(data), - }); + const dataJson = JSON.stringify(data); - if (response.status >= 200 && response.status <= 299) { - alert("Note added successfully!"); - this.reset(); // Clear the form fields - } else { - const problem = await response.json(); - alert(problem); + const xhr = new XMLHttpRequest(); + xhr.open("POST", this.action, true); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.setRequestHeader('Content-Length', dataJson.length); + xhr.send(dataJson); + + xhr.onload = function () { + if (xhr.status >= 200 && xhr.status <= 299) { + alert("Message sent successfully."); + this.reset(); // Clear the form fields + } else { + alert("An error " + xhr.status + "occurred: " + xhr.responseText); + } } - }); +});