简体   繁体   English

角度4中的空格

[英]whitespace in angular 4

Pattern that doesn't allow whitespace at the begining. 一开始不允许使用空格的模式。 Please find the code below : 请在下面找到代码:

<input class="mdl-textfield__input inputMaterial"  maxlength="100" 
[(ngModel)]="getEmpName[i]" (keydown)="onKeyPress($event)" pattern="[a-zA-Z 
]*" appFloatLabelDirective="" formControlName="employer_name">

You can take a look at the angular input-mask plugin for this kind of problem : https://github.com/assisrafael/angular-input-masks 您可以看一下针对此类问题的angular input-mask插件: https : //github.com/assisrafael/angular-input-masks

It allows you to filter inputs, and create custom directives 它允许您过滤输入,并创建自定义指令

^ [^-\\ s] [\\ w \\ s-] + $-这种模式帮助了我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM