In Aura or LWC, lightning:inputFieldandlightning-inputField inherits

salesforce's check logic about required field.

How about in LWC-open source?

We cannot use pre-built components, so must use basic html tag.

If I can use salesforce checklogic in LWC-open source?

1 Answer 1


They say you can use HTML 5 Below is some Javascript from the docs, to access the api:

import { LightningElement } from 'lwc';
export default class MyComponent extends LightningElement {

    register(event) {
        var inputCmp = this.template.querySelector(".inputCmp");
        var value = inputCmp.value;
        // is input valid text?
        if (value === "John Doe") {
            inputCmp.setCustomValidity("John Doe is already registered");
        } else {
            inputCmp.setCustomValidity(""); // if there was a custom error before, reset it
        inputCmp.reportValidity(); // Tells lightning-input to show the error right away without needing interaction

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .