
id 유효성 검사 필요한것
그리고 확인 버튼을 눌렀을때
알람창을 뜨게 할것
[Javascript] input 에서 입력 글자수 제한하는 2가지 방법
<input
type="text"
id="s"
[(ngModel)]="signidInputValue"
oninput="handleOnInput()"
/>
//아이디의 길이가 4-12 길이 oninput 이벤트 함수
handleOnInput() {
let signidInputValue = (event?.target as HTMLInputElement).value;
if (this.signidInputValue.length > this.maxLength) {
signidInputValue = this.signidInputValue.slice(0, this.maxLength);
}
// HTMLInputElement.value = signidInputValue;
}
// HTMLInputElement.oninput = this.handleOnInput
🚨이슈

< 사용자 입력 이벤트>
//
<button type="button" (click)="onClickMe()">Click me!</button>
{{ clickMessage }}`,
export class ClickMeComponent {
clickMessage = '';
onClickMe() {
this.clickMessage = 'You are my hero!';
}
⇒ 사용자가 키를 눌렀다가 떼면 keyup 이벤트가 발생 한다.
<input (keyup)="onKey($event)" />
<p>{{ values }}</p>
export class KeyUpComponent_v1 {
values = '';
onKey(event: any) { // without type info
this.values += event.target.value + ' | ';
}
길이 4-12 하기!!
버튼 클릭해서 확인하기!!
@for (id of profile; track $index) {
<div>아이디값-{{ id.id }} 아이디-{{ id.logId }}</div>
}
<input type="text" id="s" [(ngModel)]="signidInputValue" maxlength="12" />
<button (click)="idlength()">아이디 길이확인</button>
<br />
<button (click)="check()">등록 확인</button>
color() {}
idlength() {
if (this.signidInputValue.length < 4) {
// 4 미만이면 알람창 뜨게 함
alert('no');
return;
} else {
}
}

글자 색깔 바꿔서 확인 하게 못하나?