HTML5 support for older browsers

David Carr

HTML Tutorials

Sitepoint released a great post today HTML5 Forms: The Markup</a> it explains the various input tags that can be used in HTML 5. Some of these are very useful such as range, date, datetime, datetime-local, week, color. Unfortunately most of these have mixed support across browsers IE is lacking the most.

I've come across a github repo <a href='https://github.com/zoltan-dulac/html5Forms.js'>html5Forms.js</a> that "Implements a subset of the HTML5 Forms module, including calendars, colour swatches, sliding widgets, client side validation and more." meaning HTML 5 elements can be used, any browser that does not support the tags uses the js file to add support.

In order for this to work Modernizr must be used for feature detection. 
Here is an example for usage: 

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content=
        "text/html; utf-8">

        <title>HTML5 date time examples</title>

        <!-- Needed for Forms Feature Detection -->
        <script type="text/javascript" src="js/modernizr.com/Modernizr-2.5.3.forms.js">
        </script>
         
        <!-- Needed for Validation --> 
        <script type="text/javascript" src="js/html5Forms.js" data-webforms2-support="date" data-webforms2-force-js-validation="true" data-lang="qq">
        </script>    

    </head>

    <body id="myExample" class="html5Widgets-debug">

        <input type="datetime" name="DateTimeTest" value="">

    </body>
</html>

 

Fathom Analytics $10 discount on your first invoice using this link

David Carr - Laravel Developer

Hi, I’m David Carr

A Senior Developer at Vivedia
I love to use the TALL stack (Tailwind CSS, Alpine.js, Laravel, and Laravel Livewire)

I enjoy writing tutorials and working on Open Source packages.

I also write books. I'm writing a new book Laravel Testing Cookbook, This book focuses on testing coving both PestPHP and PHPUnit.

Sponsor me on GitHub

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Laravel Testing Cookbook

Help support the blog so that I can continue creating new content!

Fathom Analytics $10 discount on your first invoice using this link

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2006 - 2023 DC Blog. All code MIT license. All rights reserved.