Is there a way in HTML, javascript, or Razor to detect if the browser supports <input type="time" />
elements?
Thanks in advance.
Invalid values will be rejected when assigned to the .type
property of an input
element.
try {
var input = document.createElement("input");
input.type = "time";
if (input.type === "time") {
console.log("supported");
} else {
console.log("not supported");
}
} catch(e) {
console.log("not supported");
}
If there's some browser issue I'm not aware of, then using .innerHTML
should do the same.
var div = document.createElement("div");
div.innerHTML = "<input type='time'>";
if (div.firstChild.type === "time")
console.log("supported");
else
console.log("not supported");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With