User.attributes.phone and user.attributes.dob- needs to be made required/ mandatory in register form

In keycloak registration form I want to make phone number field and Date of birth field mandatory/ required. Without filling phone number and date of birth the form should not be submitted. It should show a validation message like other required fields. How to do this ?

below is the code

#Phone

Mobile No
<input type="text" id="user.attributes.phone" class="${properties.kcInputClass!}" name="user.attributes.phone" value="${(register.formData['user.attributes.phone']!'')}"
                />
            </div>
        </div>

#Date of Birth




Date of Birth

        <div class="${properties.kcInputWrapperClass!}">
            <input type="date" class="${properties.kcInputClass!}" 
            id="user.attributes.dob" name="user.attributes.dob" 
            value="${(register.formData['user.attributes.dob']!'')}"
            
            />
        </div>
    </div>

Declarative User Profile SPI may be your friend. See docs for details. It‘s still a preview feature.