Your best bet is probably to find polyfill(s) for the features you wish to ensure are supported.
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills
Also, I tried to use the Modernizr-framework, but did not manage that either.
Modernizr doesn't automatically fix unsupported features, but will let you know what features are available and conditionally load fallbacks.
The code works fine when I don't run the methods through this if-statement: if (!(elementSupportsAttribute(element, attribute)), but when I do, the code does not run at all.
I ran a quick test using this snippet and several HTML 5 form attributes.
function elementSupportsAttribute(element,attribute){
var test = document.createElement(element);
if (attribute in test){
return true;
}
else {
return false;
}
}
alert(elementSupportsAttribute("input", "required"));
The function does appear to work in Chrome 24: http://jsfiddle.net/eT5Ac/.
However, it would be much better to use one of Modernizr's established tests, specifically the Input Types Test.