<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Michael Holm</title>
    <description>The latest articles on DEV Community by Michael Holm (@hollo).</description>
    <link>https://dev.to/hollo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3285073%2Fe14ca9f0-ab1b-4a5f-824f-b8298c9a1cbc.jpg</url>
      <title>DEV Community: Michael Holm</title>
      <link>https://dev.to/hollo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hollo"/>
    <language>en</language>
    <item>
      <title>Why I Built My Own JavaScript Form Validator (and What I Learned Doing It)</title>
      <dc:creator>Michael Holm</dc:creator>
      <pubDate>Sun, 22 Jun 2025 16:19:50 +0000</pubDate>
      <link>https://dev.to/hollo/why-i-built-my-own-javascript-form-validator-and-what-i-learned-doing-it-oa8</link>
      <guid>https://dev.to/hollo/why-i-built-my-own-javascript-form-validator-and-what-i-learned-doing-it-oa8</guid>
      <description>&lt;p&gt;I was working on a simple landing page recently — nothing fancy, just a small form for collecting emails and passwords.&lt;/p&gt;

&lt;p&gt;I needed some validation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Required fields&lt;/li&gt;
&lt;li&gt;Minimum length&lt;/li&gt;
&lt;li&gt;A tooltip or message if something’s off&lt;/li&gt;
&lt;li&gt;Maybe even a shake animation on error (just for fun)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I like to keep things minimal and work directly with the DOM. But every validation library I found felt like too much:&lt;/p&gt;

&lt;p&gt;I had to define all the rules in JavaScript&lt;/p&gt;

&lt;p&gt;Some required importing dependencies or integrating into a framework&lt;/p&gt;

&lt;p&gt;Others didn’t support tooltips or multi-step flows natively&lt;/p&gt;

&lt;p&gt;That’s when I decided to just build my own.&lt;br&gt;
I called it BeastValidator.&lt;/p&gt;

&lt;p&gt;✅ The Basics&lt;br&gt;
BeastValidator is a small form validation library written in vanilla JS. It:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses HTML attributes (required, minlength, data-pattern, etc.)&lt;/li&gt;
&lt;li&gt;Supports tooltips or inline messages&lt;/li&gt;
&lt;li&gt;Animates fields on error (optional)&lt;/li&gt;
&lt;li&gt;Works with multi-step forms ([data-step])&lt;/li&gt;
&lt;li&gt;Supports custom and async validators&lt;/li&gt;
&lt;li&gt;Allows multilingual messages (en, da, de, even pirate 🏴‍☠️)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s a minimal example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;input name="email" type="email" required /&amp;gt;&lt;br&gt;
&amp;lt;input name="password" minlength="6" /&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;new BeastValidator('#myForm', {&lt;br&gt;
  tooltips: 'top-center',&lt;br&gt;
  shakeInput: true,&lt;br&gt;
  onSuccess: () =&amp;gt; alert('Valid! 🎉')&lt;br&gt;
});&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;🧠 Why This Approach?&lt;br&gt;
I was just tired of rewriting the same validation logic over and over again — especially because Safari sometimes doesn’t play nicely with built-in validation. I didn’t want to install a massive package just to validate two fields.&lt;/p&gt;

&lt;p&gt;This approach keeps everything in the markup, is framework-agnostic, and gives full control over UX.&lt;/p&gt;

&lt;p&gt;🧪 Try It&lt;br&gt;
🧪 &lt;a href="https://hollodk.github.io/beast-validator/" rel="noopener noreferrer"&gt;Live playground here&lt;/a&gt;&lt;br&gt;
📦 &lt;a href="https://www.npmjs.com/package/beastvalidator" rel="noopener noreferrer"&gt;npm install beast-validator&lt;/a&gt;&lt;br&gt;
📚 &lt;a href="https://github.com/hollodk/beast-validator" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💬 I'd Love Feedback&lt;br&gt;
If you have thoughts — whether it's about validation UX, the role of attributes vs JS config, or feature ideas — I’d love to hear it.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

&lt;p&gt;— Michael&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
