Shake required input field on submit

I have a newsletter sign up form and would like to recreate something similar to the below when the field is blank, it shakes the required input field:

If you’re shaking the whole form like in your example, I’d;

  • Create an interaction for your shake effect
  • Setup a button trigger for that interaction
  • Custom code to detect the form invalid submit, and click the button

If you’re trying to expand this to a more complex form setup, and do a shake on specific fields, you can use the same approach, but a lot more setup and coding.

1 Like

Thanks for the quick response.

I was able to create the shake animation and apply that on button click.

Any pointers on the custom code to validate the field and only trigger if empty?