TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dilip Gupta
1k
714
45k
Alternative for keypress event which will work on mobiles
Jun 28 2018 11:55 PM
I want to validate a Textbox using Angular 5 and it should not accept any characters other than numbers.
I have written following code, Its Working on Pc Browser but its not working on Android Mobile Browsers.
Below is my code ,
<
mat-form-field
fxFlex
=
"20"
class
=
"RightInput"
>
<
input
matInput
name
=
"Indication1PatientNo"
formControlName
=
"Indication1PatientNo"
placeholder
=
"Patient No."
(keypress)="_OnlyNumeriCkeyPress($event)"
>
</
mat-form-field
>
_OnlyNumeriCkeyPress(event: any) {
const
pattern = /[0-9\+\-\ ]/;
let inputChar = String.fromCharCode(event.charCode);
if
(!pattern.test(inputChar)) {
// invalid character, prevent input
event.preventDefault();
}
}
Reply
Answers (
0
)
why angular is called as single page application
Static Injector Error while using service in Angular.