Gabriele Ferro Home

HTML5 Built-in Form Validation

Day 47 : 19 September 2020

(While downloading and installing Watchdogs 2. It's free this week! )

**Today’s Progress:**

A few days ago, I started to write a block of JavaScript code for my 5th OpenClassRooms project. This code was used to validate a form.

Then, instead of writing several lines in JavaScript, NOW, I have chosen the EASIEST method for a client-side form validation.

Using the HTML5 form validation features, the validation has better performances but it lacks customization.

In particular, using the html5 pattern attribute, we can easily use the built-in form validation and verify the input with only a RegEx.

Under the hood, the validity state interface will check the RegEx. This interface contains several read-only flags that become true for example if an invalid pattern or a mismatch occur.


I reviewed the OpenClassRooms lesson about how to send informations using a post request, for later use.

Then I added a touch of code refactoring.


I found 2 articles that may be handy for the future ME:

**Thoughts:**

It's incredible how easy and elegant this client-side validation is, especially if compared to the equivalent JavaScript code.

**Link to tweet:**

[twitter-follow screen_name='20Gabriele20']

July 2024
MTWTFSS
1234567
891011121314
15161718192021
22232425262728
293031 

Archives

Gabriele Ferro Home
Copyright © Ferro Gabriele. All rights reserved.