<input id="phone2" type='text' mask="(000) 000-0000" [showMaskTyped]="true" class='form-control' formControlName='phone2' (keydown)='phoneChecker($event)'/> <select name='phoneType2' class='form-control' formControlName='phoneType2' id="phoneType2" > <option [value]=""></option> <option *ngFor="let phoneType of phoneTypesOther" [value]="phoneType.entityValue"> {{phoneType.entityValue}} </option> </select>Typescript:
phoneChecker(event){ //console.log(event.target.value); console.log(event.keyCode); //if its a valid numeric if((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)){ this.phoneLength = this.form.get('phone2').value; if(this.phoneLength.length==9){ this.form.get('phoneType2').enable(); }else{ this.form.get('phoneType2').setValue(''); this.phoneType2 = ""; this.form.get('phoneType2').disable(); } }else{ this.form.get('phoneType2').disable(); } }As you can see in the typescript method above on keypress when the characters are numeric and the length is < 9 I attempt to setValue to blank and disable the control. I cannot set the index value to the first option in the list which is blank. The setValue("") doesnt do it. Ive tried reset() no luck there either. The reactive form control code in typescript is below:
this.form = this.fb.group({ phoneType2: [this.phoneType2,RxwebValidators.required({conditionalExpression:(x)=>x.phone2!=''})],phoneType2: [this.phoneType2,RxwebValidators.required({conditionalExpression:(x)=>x.phone2!=''})],this.form = this.fb.group({
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.