required is NOT a custom attribute; it's part of the HTML5 standard. And true is not a valid value for it. This is probably why it's not working.
If you need custom attributes, the correct standards-compliant way to do it is to alwats prefix them with data-. This ensures that there will never be a clash with any future additions to the standard set of HTML attributes.
In this case, if you want to use the HTML5 required attribute, it works as a boolean attribute, similar to disabled and readonly, in that you only need to specify the attribute name, without a value, for it to apply. The standards-compliant HTML5 code would look like this:
<input type="text" name="foo" required maxlength="100">
This would add the required property to the element in the DOM. You can then toggle that property on or off using Javascript by setting it to true or false (ie the boolean values, not strings). And you can access in JS by simply checking whether it is set.
Note that your JS code will need to cater for the fact that in recent HTML5-compliant browsers, the browser will already be doing some validation for you when you have the required property set; you may need to drop some of your existing code when running in modern browsers, or at least adapt it to handle all cases.
If you really want to have a custom property, you would use data-required="whatever", but that's unlikley to be necessary in this case, unless you want significantly different behaviour with required to the HTML5 standard.