The MaskedInput component for Angular represents an input widget which uses a mask to distinguish between proper and improper user input. You can define phone number, ssn, zip code, dates, etc. masks by setting the jqxMaskedInput mask property.
npm install -g @angular/cli ng new jqwidgets-project cd jqwidgets-project
ng add jqwidgets-ng
jQWidgets UI for Angular is distributed as jqwidgets-ng NPM package
npm install jqwidgets-ng
@import 'jqwidgets-ng/jqwidgets/styles/jqx.base.css';
"styles": [ "node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css" ]
<div id='jqxWidget' style="font-size: 13px; font-family: Verdana;">
<div style='margin-top: 10px;'>
Numeric
</div>
<jqxMaskedInput [theme]="'fluent'" #numericInput
[width]="250"
[height]="25">
</jqxMaskedInput>
<div style='margin-top: 10px;'>
Zip Code
</div>
<jqxMaskedInput [theme]="'fluent'" #zipCodeInput
[mask]="'#####-####'"
[width]="250"
[height]="25">
</jqxMaskedInput>
<div style='margin-top: 10px;'>
SSN
</div>
<jqxMaskedInput [theme]="'fluent'" #ssnInput
[mask]="'###-##-####'"
[width]="250"
[height]="25">
</jqxMaskedInput>
<div style='margin-top: 10px;'>
Phone Number
</div>
<jqxMaskedInput [theme]="'fluent'" #phoneInput
[mask]="'(###)###-####'"
[width]="250"
[height]="25">
</jqxMaskedInput>
<div style='margin-top: 10px;'>
IP Address (ex: 255.255.255.255)
</div>
<jqxMaskedInput [theme]="'fluent'" #regexInput
[mask]="'[0-2][0-5][0-5].[0-2][0-5][0-5].[0-2][0-5][0-5].[0-2][0-5][0-5]'"
[width]="250"
[height]="25">
</jqxMaskedInput>
<div style='margin-top: 10px;'>
Disabled
</div>
<jqxMaskedInput [theme]="'fluent'" #disabledInput
[disabled]="true"
[width]="250"
[height]="25">
</jqxMaskedInput>
</div>
<br />
<jqxButton [theme]="'fluent'" #clearButton (onClick)="clear()">Clear Values</jqxButton>
import { Component, ViewChild } from '@angular/core';
import { jqxMaskedInputModule, jqxMaskedInputComponent } from 'jqwidgets-ng/jqxmaskedinput';
import { jqxButtonComponent, jqxButtonModule } from 'jqwidgets-ng/jqxbuttons';
@Component({
selector: 'app-root',
imports: [jqxMaskedInputModule, jqxButtonModule],
standalone: true,
templateUrl: './app.component.html'
})
export class AppComponent {
@ViewChild('numericInput') myNumericInput: jqxMaskedInputComponent;
@ViewChild('zipCodeInput') myZipCodeInput: jqxMaskedInputComponent;
@ViewChild('ssnInput') mySsnInput: jqxMaskedInputComponent;
@ViewChild('phoneInput') myPhoneInput: jqxMaskedInputComponent;
@ViewChild('regexInput') myRegexInput: jqxMaskedInputComponent;
@ViewChild('disabledInput') myDisabledInput: jqxMaskedInputComponent;
clear(): void {
this.myNumericInput.clear();
this.myZipCodeInput.clear();
this.mySsnInput.clear();
this.myPhoneInput.clear();
this.myRegexInput.clear();
this.myDisabledInput.clear();
}
}