Check out example codes for "password setCustomValidity html5". It will help you in understanding the concepts better.

Code Example 1

<input type="text" id="username" required placeholder="Enter Name"
    oninvalid="this.setCustomValidity('Enter User Name Here')"
    oninput="this.setCustomValidity('')"  />

Learn ReactJs, React Native from akashmittal.com