Angular 8 + .Net Core (ASPZero Version 8.7)
How to add required field validation
- Adding required feild validator cusotm code for specific TextBox, CheckBox and Dropdownlist.
- Adding required feild validator using Power tools.
5 Answer(s)
-
0
Hi @optixdev,
- You can check one of the existing pages to see how we use required field validation. You can take a look at role creation modal.
- Power Tools allows you to select a property named required when you are defining a field. So, it is very easy.
-
0
<input id="RoleDisplayName" #roleNameInput="ngModel" class="form-control" type="text" name="DisplayName" [(ngModel)]="role.displayName" required maxlength="64">
<validation-messages [formCtrl]="roleNameInput"></validation-messages>
So, we have to use only "#roleNameInput="ngModel"" in <validation-messages [formCtrl]="roleNameInput"></validation-messages> ?
-
0
Hi,
Yes, in that way,
validation-message
directive will display error message properly. -
0
Hi Ismail
how to add required field validator for <p-editor> ?
-
0
Hi,
I hven't tried this but it seems like there is an open issue on PrimeNG's GitHub repository, see https://github.com/primefaces/primeng/issues/3308. If it doesn't work, you can check the value in TypeScript code and display a message accordingly.