Reputation: 2525
i have used ng2-completer. So here based on search by code or name i am able to get dropdown values.During save if the input value is still text, the popup must throw saying, it must be a number not text in alert. How can that be handled? Here i cant limit in the input field because i need to perform search there on basis of name and code, to get the dropdown values.
HTML:
<ng2-completer inputClass="form-control" formControlName="code" [datasource]="dataService" [minSearchLength]="0" [openOnClick]="true" (input)="handleStaticResultSelected($event.target.value)" placeholder="Search Group Agent"
></ng2-completer>
TS:
this.searchForm = this.FB.group({
code: [null,Validators.required],
})
save(){
console.log(this.searchForm.value)
}
Upvotes: 1
Views: 142
Reputation: 154
In your save function you can check the value is Number or not
(if (Number (this.searchForm.value)){
alert('Yes number');
}
and then set alert. Just take care about NaN (isNaN(this.searchForm.value))
Upvotes: 2