You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a form with spam protection using the HoneyPot field. So my code is something like this:
constcontactFormDefaultValues={email: "",message: "",somethingSweet: ""}exportconstcontactFormSchema=z.object({message: z.string().min(1,"Please enter some message.").min(10,"Can you be more specific?"),email: z.string().min(1,"Please enter your e-mail.").email("Please enter a valid e-mail."),somethingSweet: z// bot honey trap.string().max(0,"Please leave this field empty."),})const[contactForm,{ Form, Field }]=useForm<ContactForm,ResponseData>({loader: {value: contactFormDefaultValues},action: useFormAction(),validate: zodForm$(contactFormSchema),})return(<Formid="contact"><Fieldname="message">{(field,props)=>(<input{...props}value={field.value}aria-invalid={!!field.error}placeholder="Your message"required/>)}</Field><Fieldname="email">{(field,props)=>(<input{...props}value={field.value}aria-invalid={!!field.error}type="email"placeholder="[email protected]"required/>)}</Field><Fieldname="somethingSweet">{(field,props)=>(<input{...props}value={field.value}aria-invalid={!!field.error}type="text"/>)}</Field></Form>)
When I use only keyboard interaction, everything works (even validation of somethingSweet field is ok). However, this is useless to me in protecting against spam. Spam is still coming. I'll try to simulate filling the value of the field with id somethingSweet using JavaScript. For example, in DevTools I use $('#somethingSweet').value = 'test' or manually change the DOM again using DevTools. When I do this, validation isn't triggered because whole form frameworks isn't able to recognise that some value has been entered. How I can do HoneyPot spam protection using Modular Forms? Is that possible? Or am I doing something wrong?
I also tried to check values present in useFormAction() method, but I'm getting the same situation. When I fill in the value using $('#somethingSweet').value = 'test' in my browser, this field looks still as unchanged.
The text was updated successfully, but these errors were encountered:
@fabian-hiller Interesting idea. If I want to do that how I can directly access the element in useFormAction()? I think that I have to create something like const honeyPotRef = useSignal<HTMLInputElement>() referencing the HTML input field. But how I can pass this const into defined action? My action method looks like this:
I'm trying to create a form with spam protection using the HoneyPot field. So my code is something like this:
When I use only keyboard interaction, everything works (even validation of
somethingSweet
field is ok). However, this is useless to me in protecting against spam. Spam is still coming. I'll try to simulate filling the value of the field with idsomethingSweet
using JavaScript. For example, in DevTools I use$('#somethingSweet').value = 'test'
or manually change the DOM again using DevTools. When I do this, validation isn't triggered because whole form frameworks isn't able to recognise that some value has been entered. How I can do HoneyPot spam protection using Modular Forms? Is that possible? Or am I doing something wrong?I also tried to check values present in
useFormAction()
method, but I'm getting the same situation. When I fill in the value using$('#somethingSweet').value = 'test'
in my browser, this field looks still as unchanged.The text was updated successfully, but these errors were encountered: