SMF 2.1 uses HTML 5, for example:
<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:
<input type="text" ... /> (YYYY-MM-DD)
In SMF 2.1 I can use an input date button
<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:
<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:
<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!):
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.
2.1 assumes HTML5. You can too, since all major browsers support it in general.
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.
However, not all HTML 5 input types are equally supported by all browsers. I recommend checking caniuse.com when making these decisions.