Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48980

$event.PreventDefault not working in ion-input with ionInput Event

$
0
0

Hello…I am submitting an issue related to DOM management in ionInput.
i want to use the ionInput event to fire at every time entering a input and check with the regular expression to validate input if not valid i want to remove the data.
it was possible in angular with $event.preventDefault() and i also tried $event.stopPropgation();
here is my Code.
html:
<ion-input type=“text” autocapitalize=“on” (ionInput)=“checkIfvalid($event)” clearInput >

type script:
checkIfvalid(event) {
console.log(event.detail.data);
if (/\d/.test(event.detail.data)) {
console.log(‘i am digit’);
event.preventDefault();
event.stopPropagation();
} else {
console.log(‘i am alphabet’);
event.stopPropagation();
event.stopPropagation();
}
}

Here are dependencies:
“dependencies”: {
@angular/common”: “~12.0.1”,
@angular/core”: “~12.0.1”,
@angular/forms”: “~12.0.1”,
@angular/platform-browser”: “~12.0.1”,
@angular/platform-browser-dynamic”: “~12.0.1”,
@angular/router”: “~12.0.1”,
@capacitor/core”: “3.0.1”,
@ionic/angular”: “^5.5.2”,
“rxjs”: “~6.6.0”,
“tslib”: “^2.0.0”,
“zone.js”: “~0.11.4”
},
“devDependencies”: {
@angular-devkit/build-angular”: “~12.0.1”,
@angular-eslint/builder”: “~12.0.0”,
@angular-eslint/eslint-plugin”: “~12.0.0”,
@angular-eslint/eslint-plugin-template”: “~12.0.0”,
@angular-eslint/template-parser”: “~12.0.0”,
@angular/cli”: “~12.0.1”,
@angular/compiler”: “~12.0.1”,
@angular/compiler-cli”: “~12.0.1”,
@angular/language-service”: “~12.0.1”,
@capacitor/cli”: “3.0.1”,
@ionic/angular-toolkit”: “^4.0.0”,
@types/jasmine”: “~3.6.0”,
@types/jasminewd2”: “~2.0.3”,
@types/node”: “^12.11.1”,
@typescript-eslint/eslint-plugin”: “4.16.1”,
@typescript-eslint/parser”: “4.16.1”,
“eslint”: “^7.6.0”,
“eslint-plugin-import”: “2.22.1”,
“eslint-plugin-jsdoc”: “30.7.6”,
“eslint-plugin-prefer-arrow”: “1.2.2”,
“jasmine-core”: “~3.7.1”,
“jasmine-spec-reporter”: “~5.0.0”,
“karma”: “~6.3.2”,
“karma-chrome-launcher”: “~3.1.0”,
“karma-coverage”: “~2.0.3”,
“karma-coverage-istanbul-reporter”: “~3.0.2”,
“karma-jasmine”: “~4.0.0”,
“karma-jasmine-html-reporter”: “^1.5.0”,
“protractor”: “~7.0.0”,
“ts-node”: “~8.3.0”,
“typescript”: “~4.2.4”
},
“description”: “An Ionic project”
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>