How to do field validation on lightning:recordEditForm with lightning:inputField

You are not able to use validity on lightning:inputField because the attribute is not supported on this component, instead its an attribute for lighting:input.

For validating lightning:inputField with lightning:recordEditForm, you can refer to this answer which provides a perspective as how you can validate values entered on the component.

For the error scenarios, you can utilize the CSS that's available for the purpose. You can refer to more on this on SLDS documentation for the component from where it inherits the styling.


One way to catch and throw error messages without having to write any custom code is to include <lightning:messages/> in the component and set the fields to required at the object level. Heres an example of that

If you are unable to do that for your org my advice would be to switch to lightning:input as it is one of the few tags that currently supports custom client side validation