1.0.0 • Published 4 years ago

angular-weblineindia-password v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

AngularJS - Password Input Component

An AngularJS based Password Input component, which provides input field to add password as a text / password property with validation. The password value is automatically validated on change event. You can also disable password field using disable props.

Table of contents

Browser Support

ChromeFirefoxSafariEdgeIE
83.0 ✔77.0 ✔13.1.1 ✔83.0 ✔11.9 ✔

Demo

npm.io

Getting started

Install the npm package:

npm install angular-weblineindia-password
#OR
yarn add angular-weblineindia-password

If your angular verson is diffrent then install fontawesome :

Using ng add:

# See Compatibility table below to choose a correct version
$ ng add @fortawesome/angular-fontawesome@<version>

Using Yarn

$ yarn add @fortawesome/fontawesome-svg-core
$ yarn add @fortawesome/free-solid-svg-icons
# See Compatibility table below to choose a correct version
$ yarn add @fortawesome/angular-fontawesome@<version>

Using NPM

$ npm install @fortawesome/fontawesome-svg-core
$ npm install @fortawesome/free-solid-svg-icons
# See Compatibility table below to choose a correct version
$ npm install @fortawesome/angular-fontawesome@<version>
@fortawesome/angular-fontawesomeAngularng-add
0.1.x5.xnot supported
0.2.x6.xnot supported
0.3.x6.x && 7.xnot supported
0.4.x, 0.5.x8.xnot supported
0.6.x9.xsupported

Usage

Use the <angular-weblineindia-password> component:

import { NgModule } from '@angular/core';
import { PasswordModule } from 'angular-weblineindia-password';

@NgModule({
  imports: [PasswordModule]
})
export class AppModule {}

Add typescript on .ts file

export class AppComponent {

 passwordValue: any = {
    value: "",
    placeholder: "Enter Password",
    name: "password",
    id: "password",
    disabled: "false",
    tabindex: "1",
    paswordMinLength: 3,
    passwordFieldType: 'password',
    paswordMaxLength:255,
    passwordErrorName:'The password field must be at least 3 characters'
  };

 onChangePassword(event) {
    if (event.target.value.trim() === "") {
      this.passwordValue.value = event.target.value
        .replace(/^[^-\s][a-zA-Z0-9_\s-]+$/, "")
        .trim();
    } else {
      this.passwordValue.value = event.target.value;
    }
  }

  onFocusPassword(event) {
    event.target.placeholder = "";
  }
  onBlurPassword(event) {
    event.target.placeholder = this.passwordValue.placeholder;
  }
}

Add html on .html file

<lib-password
  [placeholder]="passwordValue.placeholder"
  [name]="passwordValue.name"
  [value]="passwordValue.value"
  [id]="passwordValue.id"
  [disabled]="passwordValue.disabled"
  [tabindex]="passwordValue.tabindex"
  [paswordMinLength]="passwordValue.paswordMinLength"
  [paswordMaxLength]="passwordValue.paswordMaxLength"
  [passwordFieldType]="passwordValue.passwordFieldType"
  [passwordErrorName]="passwordValue.passwordErrorName"
  (change)="onChangePassword($event)"
  (focus)="onFocusPassword($event)"
  (blur)="onBlurPassword($event)"
></lib-password>

Available Props

PropTypedefaultDescription
paswordMinLengthNumber3min length for password
paswordMaxLengthNumber255max length for password
passwordFieldTypeStringpasswordfield type of password(like text or password)
passwordErrorNameStringThe password field must be at least 3 characterserror name for password
placeholderStringpasswordpassword placeholder
disabledBooleanfalsedisable password field
nameStringpasswordname for password field
tabindexNumber1password tabIndex
idStringpasswordname for password field
hideBooleanfalsefor hide password field
isViewPasswordBooleantrueTo hide/show eye icon
valueStringvalue for password

Methods

NameDescription
focusGets triggered when the password input field receives focus.
blurGets triggered when the password input field loses focus.
changeGets triggered every time password got changed.

Want to Contribute?

  • Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part).
  • Fork it.
  • Create new branch to contribute your changes.
  • Commit all your changes to your branch.
  • Submit a pull request.

Collection of Components

We have built many other components and free resources for software development in various programming languages. Kindly click here to view our Free Resources for Software Development


Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT

Keywords

angular-weblineindia-password, password-input, angular-components, angularjs, angularjs-component, password-input-component, angularjs-password-input, password-validation, angularjs-password-validation