Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: davidhs on April 07, 2019, 12:06:03 PM

Title: HTML requirements
Post by: davidhs on April 07, 2019, 12:06:03 PM
SMF 2.1 uses HTML 5, for example:
Code (HTML) Select

<input type="number" ...>


Some of my mods have buttons for accept dates in admin area. In SMF 2.0 I use an input text button with an explanation about format:
Code (HTML) Select

<input type="text" ... /> (YYYY-MM-DD)


In SMF 2.1 I can use an input date button
Code (HTML) Select

<input type="date" ...>

and I do not need add explanation.

If user navigator has support for HTML 5 and input date button, all works fine. Else, user see only an input text button, with not help about format.

My question is:
1. Can I suppose SMF 2.1 has HTML 5 as minimum requirement?
If yes, I will use HTML 5 buttons with not explanation:
Code (HTML) Select

<input type="date" ...>


2. Else, has SMF any JavaScript code in order to know the navigator support for HTML 5?
If yes, I will use HTML 5 buttons with explanation when no support for HTML 5:
Code (HTML) Select

<input type="date" ...> <span id="no_html5">(YYYY-MM-DD)</span>
<script>
document.getElementById('no_html5').style.display = !html5.inputdate ? '' : 'none';
</script>


3. Else, I can do something like this (no tested!):
Code (JavaScript) Select

function support_html5(tag, attr, value)
{
var new_tag = document.createElement(tag);

new_tag.setAttribute(attr, value);
return value === new_tag.getAttribute(attr);
}
document.getElementById('no_html5').style.display = !support_html5('input', 'type', 'date') ? '' : 'none';


Comment: If HTML 5 is not minimum requirement and SMF has not a JavaScript function of support for HTML5, could be added.
Title: Re: HTML requirements
Post by: Arantor on April 07, 2019, 12:10:23 PM
2.1 assumes HTML5. You can too, since all major browsers support it in general.
Title: Re: HTML requirements
Post by: davidhs on April 07, 2019, 12:36:38 PM
Quote from: Arantor on April 07, 2019, 12:10:23 PM
2.1 assumes HTML5. You can too, since all major browsers support it in general.
Ok, thank you.
Title: Re: HTML requirements
Post by: Sesquipedalian on April 08, 2019, 11:54:24 AM
However, not all HTML 5 input types are equally supported by all browsers. I recommend checking caniuse.com when making these decisions.