Dùng setCustomValidity(message) trên input element.
- Message rỗng = valid.
- Kết hợp
patternattribute với regex, lắng ngheinvalidevent. - Có thể dùng
novalidatetrên form rồi validate bằng JS.
Use setCustomValidity(message) on the input element.
- An empty message means valid.
- Combine with the
patternattribute and regex, and listen to theinvalidevent. - You can also add
novalidateto the form and handle all validation manually in JavaScript.