added honeypot field on contact form

This commit is contained in:
Sergey Yarkov 2026-10-12 09:32:26 +03:00
parent 97fa1a5b4e
commit b7b0a6f4d5
2 changed files with 14 additions and 0 deletions

View File

@ -11,10 +11,13 @@ export const server = {
input: z.object({
name: z.string(),
email: z.string().email(),
website_url: z.string().optional(), // honeypot field
subject: z.string(),
message: z.string(),
}),
handler: async (data, ctx) => {
if (data.website_url && data.website_url.trim() !== "") return true;
const currentDate = new Date();
const latestAppeals = await getLatestAppealsByClientIp(ctx.clientAddress, 5);
const appealsLastHrs = latestAppeals.filter((a) => {

View File

@ -17,6 +17,10 @@ const formResult = Astro.getActionResult(actions.appeal);
<div>
<input name="email" placeholder="example@email.com" type="email" autocomplete="off" required />
</div>
<div class="hp-field" aria-hidden="true">
<label for="website_url">Оставьте это поле пустым:</label>
<input type="text" autocomplete="off" id="website_url" name="website_url" tabindex="-1" autocomplete="off" />
</div>
</div>
<input name="subject" placeholder={t("input.subjectField")} type="text" autocomplete="off" required />
<textarea
@ -48,6 +52,13 @@ const formResult = Astro.getActionResult(actions.appeal);
flex-direction: column;
row-gap: 7px;
margin-bottom: 3.125rem;
& .hp-field {
position: absolute;
left: -9999px;
top: -9999px;
opacity: 0;
pointer-events: none;
}
& .flex {
column-gap: 10px;
& div {