Added setRequired method to automatically add an html5 required attribute

Added setRequired method to automatically add an html5 required attribute if a form element is required.