[SalesForce] Required=”true” not working with apex:inputsecret

I am using apex:inputsecret with required="true", but this is not working. When I check in Inspect element of Chrome, the required attribute is not shown.
If I add required="true" from Inspect element then it works. Can anybody help me in this?

Best Answer

Salesforce does not add the required HTML attribute to your fields when setting required="true" on a component.

Setting the component's required attribute indicates that Salesforce should validate that the field is required on the server-side. This differs from the HTML version of the required attribute which does the validation on the client-side.

What you are seeing is the expected behaviour.

If you add an apex:pageMessages component to your page and try and call an action or anything that will submit your form then you should get an error message if your apex:inputSecret is blank.

Related Topic