Karthey Sundarem
asked on
How can I change generic tool tip in HTML5 for input angular form field
Hi,
I am using Angular2 form. Mostly all validated using html pattern and some are form validated. For html validation, I am getting generic tooltip "Please enter a valid format" for phone without saying the format. How can I change it to "Please enter 10 numeric values."
HTML Code
<div class="row form-group">
<div class="col-xs-12">
<div class="float-label active">
<input type="text" class="input-underline-blu e" id="phone" formControlName="phone"
placeholder="(123) 345-2222"
(keydown)="numOnlyDown($ev ent)"
(keyup)="numOnlyUp($event) "
(blur)="phoneUSFormat($eve nt)"
[maxlength]="14"
pattern="(?:\([1-9]\d{2}\) |\d{3})[- ]?\d{3}[- ]?\d{4}"
required />
<label for="phone">@Html.Sitecore ().Field(" Phone Label", profileItem)</label>
<div *ngIf="!editInfoForm.get(' phone').va lid" class="alert alert-danger alert-small">
<span *ngIf="editInfoForm.get('p hone').has Error('req uired')">
@Html.Sitecore().Field("Ph one Required", profileItem)
</span>
<span *ngIf="!editInfoForm.get(' phone').ha sError('re quired') && !editInfoForm.get('phone') .valid">
Enter a valid phone number.
</span>
</div>
</div>
</div>
</div>
I am using Angular2 form. Mostly all validated using html pattern and some are form validated. For html validation, I am getting generic tooltip "Please enter a valid format" for phone without saying the format. How can I change it to "Please enter 10 numeric values."
HTML Code
<div class="row form-group">
<div class="col-xs-12">
<div class="float-label active">
<input type="text" class="input-underline-blu
placeholder="(123) 345-2222"
(keydown)="numOnlyDown($ev
(keyup)="numOnlyUp($event)
(blur)="phoneUSFormat($eve
[maxlength]="14"
pattern="(?:\([1-9]\d{2}\)
required />
<label for="phone">@Html.Sitecore
<div *ngIf="!editInfoForm.get('
<span *ngIf="editInfoForm.get('p
@Html.Sitecore().Field("Ph
</span>
<span *ngIf="!editInfoForm.get('
Enter a valid phone number.
</span>
</div>
</div>
</div>
</div>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Complex_constraints_using_HTML5_Constraint_API
https://www.grapecity.com/en/blogs/easy-form-validation-in-angularjs/