How to validate your form with HTML5

Some forms require validations to ensure that users enter the correct data. While FormKeep does have some server-side validation using our Field Rules to detect spam, you can validate your form client-side with either HTML5 or JavaScript.

The benefit of HTML5 validations is that they take minimal effort to implement. You add a few attributes to your markup and you’re good to go. The downside is that it is still unsupported in some browsers. Depending on your needs, a lightweight solution like this may be enough.

HTML5 gives you a lot, from marking fields as required, to size limits, to ensuring emails look like emails. Here’s a taste:

<input name="name" type="text" required>

Mark a field as required with the required attribute:

<input type="email" name="email">

Ensure an email address is formatted correctly

<input name="email" type="url">

Ensure a URL is formatted correctly

<input name="age" type="number" min="18" max="99" value="21">

Ensure a number is with a range

<textarea name="bio" minlength="50" maxlength="300"></textarea>

You can also limit the characters in a text input or textarea

<input type="text" name="email" placeholder="work email" pattern="^((?!(gmail.com|hotmail.com|yahoo.com)).)*$" title="Work email addresses only">

Maybe you want to not allow certain email service providers. This will not allow gmail.com, hotmail.com or yahoo.com email addresses from being entered.