2
hello, I’m beginner with angular 4, I’m trying to make a mask for a text type field to validate a value in m².
The Mask class contains the method to create the mask, the given value can be between 1 and unlimited.
wanted the method returns something in this context: 1.000.000,00 or 10.000,00 or 1.000,00
export class Mask
{
public static getArea():Array<string|RegExp>
{
return [/\d/,/\d/,/\d/,'.',/\d/,/\d/,/\d/,'.',/\d/,/\d/,/\d/,',',/\d/,/\d/];
}
}
<input formControlName="areaImovel" [textMask]="{ mask: areaMask }" type="text" id="form-area-imovel" class="form-control">
Calling on the Component
import { Mask } from './mask';
export class EnderecoComponent implements OnInit {
public areaMask = Mask.getArea();
constructor(){}
}
What’s the matter ?
– André Roggeri Campos
Try this Regex:
\d{1,3}(?:\.\d{3})+,\d{2}$
and the demo on Regex101. For field validation.– danieltakeshi