Magento – “Telephone” is a required value not working in customer edit form

customerform-validationformsmagento2

In my customer edit form, for telephone phone, required field validation is not working when I leave the telephone field blank.
The required validation works for every field except for the telephone field.

When I save the form without telephone field, after the backend call it gives me a notification message " telephone" is required. Enter and try again.

enter image description here

This is code for password field in my form

<div class="field telephone required">
<label for="telephone" class="label">
    <span>
        Phone Number 
    </span>
</label>
<div class="control">
    <input type="text" name="telephone" id="telephone" value="" title="Phone Number" class="input-text " sr-only="INPUT" for="INPUT" aria-required="true">
</div>

I even checked eav_attribute table. It has is_required=1 for attribute_code='telephone'

I don't want notification, it should be like other fields inline validation.

Best Answer

You just need to add required-entry class in the input field as:

<input type="text" name="telephone" id="telephone" value="" title="Phone Number" class="input-text required-entry" sr-only="INPUT" for="INPUT" aria-required="true">

Its working fine for me.