Advertisement:
GCWebhosting

Author Topic: HTML requirements  (Read 369 times)

Offline davidhs

  • Sophist Member
  • *****
  • Posts: 1,050
  • Gender: Male
HTML requirements
« 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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,196
    • StoryBB/StoryBB on GitHub
Re: HTML requirements
« Reply #1 on: April 07, 2019, 12:10:23 PM »
2.1 assumes HTML5. You can too, since all major browsers support it in general.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline davidhs

  • Sophist Member
  • *****
  • Posts: 1,050
  • Gender: Male
Re: HTML requirements
« Reply #2 on: April 07, 2019, 12:36:38 PM »
2.1 assumes HTML5. You can too, since all major browsers support it in general.
Ok, thank you.

Offline Sesquipedalian

  • The Mad Doctor
  • On Hiatus
  • Sr. Member
  • *
  • Posts: 904
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: HTML requirements
« Reply #3 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.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.