Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular reactive forms bootstrap 4

<div class="register-form">
  <form [formGroup]="form" (ngSubmit)="onSubmit()">
    <div class="form-group">
      <label>Full Name</label>
      <input
        type="text"
        formControlName="fullname"
        class="form-control"
        [ngClass]="{ 'is-invalid': submitted && f.fullname.errors }"
      />
      <div *ngIf="submitted && f.fullname.errors" class="invalid-feedback">
        <div *ngIf="f.fullname.errors.required">Fullname is required</div>
      </div>
    </div>
    <div class="form-group">
      <label>Username</label>
      <input
        type="text"
        formControlName="username"
        class="form-control"
        [ngClass]="{ 'is-invalid': submitted && f.username.errors }"
      />
      <div *ngIf="submitted && f.username.errors" class="invalid-feedback">
        <div *ngIf="f.username.errors.required">Username is required</div>
        <div *ngIf="f.username.errors.minlength">
          Username must be at least 6 characters
        </div>
        <div *ngIf="f.username.errors.maxlength">
          Username must not exceed 20 characters
        </div>
      </div>
    </div>
    <div class="form-group">
      <label>Email</label>
      <input
        type="text"
        formControlName="email"
        class="form-control"
        [ngClass]="{ 'is-invalid': submitted && f.email.errors }"
      />
      <div *ngIf="submitted && f.email.errors" class="invalid-feedback">
        <div *ngIf="f.email.errors.required">Email is required</div>
        <div *ngIf="f.email.errors.email">Email is invalid</div>
      </div>
    </div>
    <div class="form-group">
      <label>Password</label>
      <input
        type="password"
        formControlName="password"
        class="form-control"
        [ngClass]="{ 'is-invalid': submitted && f.password.errors }"
      />
      <div *ngIf="submitted && f.password.errors" class="invalid-feedback">
        <div *ngIf="f.password.errors.required">Password is required</div>
        <div *ngIf="f.password.errors.minlength">
          Password must be at least 6 characters
        </div>
        <div *ngIf="f.password.errors.maxlength">
          Username must not exceed 40 characters
        </div>
      </div>
    </div>
    <div class="form-group">
      <label>Confirm Password</label>
      <input
        type="password"
        formControlName="confirmPassword"
        class="form-control"
        [ngClass]="{ 'is-invalid': submitted && f.confirmPassword.errors }"
      />
      <div
        *ngIf="submitted && f.confirmPassword.errors"
        class="invalid-feedback"
      >
        <div *ngIf="f.confirmPassword.errors.required">
          Confirm Password is required
        </div>
        <div *ngIf="f.confirmPassword.errors.matching">
          Confirm Password does not match
        </div>
      </div>
    </div>
    <div class="form-group form-check">
      <input
        type="checkbox"
        formControlName="acceptTerms"
        class="form-check-input"
        [ngClass]="{ 'is-invalid': submitted && f.acceptTerms.errors }"
      />
      <label for="acceptTerms" class="form-check-label"
        >I have read and agree to the Terms</label
      >
      <div *ngIf="submitted && f.acceptTerms.errors" class="invalid-feedback">
        Accept Terms is required
      </div>
    </div>
    <div class="form-group">
      <button type="submit" class="btn btn-primary">Register</button>
      <button
        type="button"
        (click)="onReset()"
        class="btn btn-warning float-right"
      >
        Reset
      </button>
    </div>
  </form>
</div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: get random hsl color js 
Javascript :: get random item in array 
Javascript :: nodejs stream pipeline 
Javascript :: javascript fiori 
Javascript :: find numeric Unicode value of the character with charCodeAt() method 
Javascript :: condition rendering using if-else 
Javascript :: free robux javascript 2022 
Javascript :: moment js with nodejs 
Javascript :: offline bot command discord.js 
Javascript :: jquery selectors 
Javascript :: javascript prompts user to input 
Javascript :: js foreach syntax 
Javascript :: password 
Javascript :: js print 
Javascript :: nodejs extract pdf data 
Javascript :: define function javascript 
Javascript :: js functional ajax requests 
Javascript :: react create context 
Javascript :: how to use the javascript console 
Javascript :: remove array from array javascript 
Javascript :: how to get the last element of an array in javascript 
Javascript :: react native generate signed apk getting older version 
Javascript :: javascrip functions parameters 
Javascript :: how to reload webview in react native 
Javascript :: update text react native 
Javascript :: vars javascript 
Javascript :: javascript remove last word from string 
Javascript :: jquery set timezone 
Javascript :: php math 
Javascript :: javascript interface class 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =