Day Five: Form Updates

I spent most of today writing, but I was determined to put aside some time to make the semantic and regex updates I mentioned yesterday.

And I did!

While trying to decide if I should break my form up using <section> elements, I came across the <fieldset> and <legend> elements in the MDN documentation, so I went with those instead. I was pleasantly surprised at how they also sectioned off my form on the front-end.

HTML form revised with the use of semantic elements.
HTML form revised with the use of semantic elements.

I also dropped in a bit of regex to restrict the phone number field to the correct format using the pattern attribute:

<label for ="phone">Phone Number *</label>
<input id="phone" name="phone" type="tel" placeholder="e.g. 123-4567" pattern="[0-9]{3}-[0-9]{4}" required>

Check out the updated code in codepen here.

I think I’m ready to proceed to CSS review tomorrow and start styling this bad boy!

Leave a comment