For simplicity when building a two column form I built it in two separated divs using flex box. The form however reads from left to right i.e First Name at the top of div one and Surname at the top of div two. If the user uses the tab key to move between inputs the tab key moves down the form rather than across. This was an oversight by me but I was wondering if the tabbing between inputs could be set different from the default. Maybe a picture would help.
So I would like to change it to tab across. How would I do that? Also the actual form is more complicated than shown below so I don't want to rebuild the html.
My HTML
<div fxLayout="row" fxLayout.lt-sm="column" fxLayoutAlign="space-between center">
<div fxFlex="40">
<mat-form-field class="formFieldLeft">
<div class="is-size-7 has-text-grey-light mbxs">First Name</div>
<input matInput formControlName="firstName">
</mat-form-field>
<mat-form-field class="formFieldLeft">
<div class="is-size-7 has-text-grey-light mbxs">Email Address</div>
<input matInput formControlName="email">
</mat-form-field>
<mat-form-field class="formFieldLeft mblg">
<div class="is-size-7 has-text-grey-light mbxs">Company Phone Number</div>
<input matInput formControlName="companyPhoneNumber">
</mat-form-field>
<div fxFlex="60">
<mat-form-field class="formFieldRight">
<div class="is-size-7 has-text-grey-light mbxs">Surname</div>
<input matInput formControlName="lastName">
</mat-form-field>
<mat-form-field class="formFieldRight">
<div class="is-size-7 has-text-grey-light mbxs">Job Title</div>
<input matInput formControlName="jobTitle">
</mat-form-field>
<mat-form-field class="formFieldRight mblg">
<div class="is-size-7 has-text-grey-light mbxs">Mobile Number</div>
<input matInput formControlName="mobilePhoneNumber">
</mat-form-field>
</div>
Add tabIndex like
<input tabindex="3">
<input tabindex="0">
<input tabindex="-1">
<input>
<input tabindex="2">
<input tabindex="1">
see this for more details
You can save active tab index and create separate function on
(keyup)="onKeypressEvent($event)" {
// check does it `tab`
}
chech the key code and depending of where you current tab active change next active tab
Related
Autofill is triggering separately for billing and for contact information.
For example, when I click on any of the following 4 input fills it offers autofill for them => first name, last name, phone number and email. When I click on any of the following 4 it triggers autofill for them together => billing address, billing postal-code, billing country, billing city.
Autofill works well for each of the two groups, but I want it to be one group that will autofill by selecting any of the 8 input fields.
Code example (I'm using Angular 8 with Material design components but I think this shouldn't pose as a distraction since I see this as a HTML issue):
<form method="post" id="paymentForm" [formGroup]="formGroup" (ngSubmit)="onSubmit(formGroup.value)" class="form" >
<div class="customer-info">
<div class="customer-info-personal">
<div>
<mat-form-field class="form-element">
<input name="fname" matInput placeholder="Ime" formControlName="firstName" autocomplete="given-name" form="paymentForm">
<mat-error
*ngIf="!formGroup.controls['firstName'].valid && formGroup.controls['firstName'].touched">
</mat-error>
</mat-form-field>
<mat-form-field class="form-element">
<input name="lname" matInput placeholder="Prezime" formControlName="lastName" autocomplete="family-name" form="paymentForm">
<mat-error *ngIf="!formGroup.controls['lastName'].valid && formGroup.controls['lastName'].touched">
</mat-error>
</mat-form-field>
<mat-form-field class="form-element">
<input name="bill-address" matInput placeholder="Adresa" formControlName="billingAddress" autocomplete="billing street-address" form="paymentForm">
<mat-error *ngIf="!formGroup.controls['billingAddress'].valid && formGroup.controls['billingAddress'].touched">
</mat-error>
</mat-form-field>
<mat-form-field class="form-element">
<input name="bill-city" matInput placeholder="Grad" formControlName="billingCity" autocomplete="billing address-level2" form="paymentForm">
<mat-error *ngIf="!formGroup.controls['billingCity'].valid && formGroup.controls['billingCity'].touched">
</mat-error>
</mat-form-field>
</div>
<div>
<mat-form-field class="form-element">
<input name="bill-zip" matInput placeholder="Poštanski broj" formControlName="billingPostalNumber" autocomplete="billing postal-code" form="paymentForm">
<mat-error
*ngIf="!formGroup.controls['billingPostalNumber'].valid && formGroup.controls['billingPostalNumber'].touched">
</mat-error>
</mat-form-field>
<mat-form-field class="form-element">
<input name="bill-country" matInput placeholder="Država" formControlName="billingCountry" autocomplete="billing country" form="paymentForm">
<mat-error *ngIf="!formGroup.controls['billingCountry'].valid && formGroup.controls['billingCountry'].touched">
</mat-error>
</mat-form-field>
<mat-form-field class="form-element">
<input name="email" matInput placeholder="e-mail" formControlName="email" autocomplete="email" type="email" form="paymentForm">
<mat-error *ngIf="!formGroup.controls['email'].valid && formGroup.controls['email'].touched">
</mat-error>
</mat-form-field>
<mat-form-field class="form-element">
<input name="phone" matInput placeholder="Broj telefona" formControlName="phoneNumber" autocomplete="tel" type="tel" form="paymentForm">
<mat-error
*ngIf="!formGroup.controls['phoneNumber'].valid && formGroup.controls['phoneNumber'].touched">
</mat-error>
</mat-form-field>
</div>
</div>
<div class="buttons-element">
<div class="pay-button-element">
<button mat-raised-button color="primary" type="submit" class="button"
[disabled]="!formGroup.valid">Plati</button>
</div>
<div class="cancel-button-element">
<button mat-button color="secondary" type="submit" class="button">Odustani</button>
</div>
</div>
</div>
</form> ```
Fixed it by removing the word billing from autocomplete values and bill- from name values.
E.g.
Before autocomplete="billing postal-code" name="zip"
Before autocomplete="postal-code" name="zip"
Changing the autocomplete field alone proved to be enough.
I am new in Angular and I have to create an input field like that:
Everything is ok besides the Vorname placeholder on the top.
How can I put it there?
I am using Angular Materials.
<div class='grid-container-left'>
<mat-form-field appearance="outline">
<input matInput placeholder={{angeforderteVerfueger.request.vorname}} readonly>
</mat-form-field>
</div>
Thank you in advance!
Answer:
The below provided solutions works, just have to add floatLabel value with always.
<mat-form-field appearance="outline" floatLabel="always">
<mat-label>Vorname</mat-label>
<input matInput [placeholder]="angeforderteVerfueger.request.vorname" readonly>
</mat-form-field>
Try to add a label before your input:
<mat-label>Vorname</mat-label>
What you are doing is binding a property using string interpolation which is the wrong syntax. Try this
<div class='grid-container-left'>
<mat-form-field appearance="outline">
<mat-label>Vorname</mat-label>
<input matInput [placeholder]="angeforderteVerfueger.request.vorname" readonly>
</mat-form-field>
</div>
I need to put two input fields with labels as below.
But In using angular, some data R fields related input not visible. Then, it should be like below.
My code
<div>
<div>
<label i18n="k" *ngIf="model" id="'k'">
<br />
<br />
K:
{{model.k}} </label>
<label i18n="N" *ngIf="model"
id="'N'">
<br />
<br />
N:
{{model.n}} </label>
</div>
<div>
<mat-form-field [formGroup]="DetailForm">
<label *ngIf="isVisible(model.r)">R</label>
<input *ngIf="isVisible(model.r)" matInput formControlName="rate"
[type]="'number'" [placeholder]="'rate'" [required]="false" [readonly]="false" [spaced]="false">
<label>Comment</label>
<input matInput formControlName="c" [type]="'text'" [placeholder]="'comment'" [required]="false"
[readonly]="false" [spaced]="false">
</mat-form-field>
</div>
</div>
But I tried a different way when two input available it shows like below.
need some expert help to resolve this.
I think you need to use 2 different mat-form-fields like this:
<mat-form-field>
<mat-label>Rate</mat-label>
<input matInput placeholder="Placeholder">
</mat-form-field>
<mat-form-field>
<mat-label>Comment</mat-label>
<input matInput placeholder="Placeholder">
</mat-form-field>
Or have a look at this stackblitz, i put a very small demo of the above changes there:
https://stackblitz.com/edit/angular-material-starter-r7khp2
I want a material input field and a material select in one line(inside one form field). To get it done I wrote the below code but it goes into two rows. How can I get this input and drop-down in one line?.
Expected result:
Frontend view
My html code :
<div fxLayout="column" class="mat-elevation-z8">
<mat-form-field class="p-1">
<input matInput placeholder="Search table..."
(keyup)="updateFilter($event)">
<mat-select name="ampm" [(ngModel)]="selectedtablesearch" (selectionChange)="updateFilter($event)">
<mat-option *ngFor="let draft_tblselect of draft_tblselects"
[value]="draft_tblselect.viewValue">{{draft_tblselect.viewValue}}</mat-option>
</mat-select>
</mat-form-field>
</div>
I've sorted this issue.
Code:
<div fxLayout="row" class="mat-elevation-z8">
<div fxFlex="80" class="p-2">
<mat-form-field class="w-100">
<input matInput placeholder="Search table..." (keyup)="updateFilter($event)">
</mat-form-field>
</div>
<div fxFlex="20" class="p-2">
<mat-form-field class="w-100">
<mat-select [(ngModel)]="selectedtablesearch" (selectionChange)="updateFilter($event)">
<mat-option *ngFor="let draft_tblselect of draft_tblselects"
[value]="draft_tblselect.viewValue">{{draft_tblselect.viewValue}}</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
I am having 2 fields in my angular application. I am using data binding for these two fields because these 2 fields have same data. However, in one of the field I need to enabled it and the other I need to disable it.
I found that both of my field is disabled now when I disabled="true" in one of the fields. Any solutions to only disabled one of the field and the other of the field is enabled?
The following is my source code.
<div class="row">
<div class="col-4">
<label>{{ 'company-info.performance.Red' | translate }}</label>
</div>
<div class="col-2">
<mat-form-field>
<input matInput type="number" min="0" max="100" placeholder="less than %" [(ngModel)]="data.nonprfmCustT1" name="nonprfmCustT1">
</mat-form-field>
</div>
</div>
<div class="row">
<div class="col-4">
<label>{{ 'company-info.performance.Amber' | translate }}</label>
</div>
<div class="col-2">
<mat-form-field>
<input matInput [disabled]="true" type="number" placeholder="higher than or Equal %" [(ngModel)]="data.nonprfmCustT1" name="nonprfmCustT1">
</mat-form-field>
<mat-form-field>
<input matInput type="number" min="data.nonprfmCustT1" max="100" placeholder="less than %" [(ngModel)]="data.nonprfmCustT2" name="nonprfmCustT2">
</mat-form-field>
</div>
</div>
Next, how can I set min value of nonprfmCustT2 must be greater than nonprfmCustT1?