input uppercase code example

Example 1: conveert text to uppercase in input field

<input type="text" class="normal" 
       name="Name" size="20" maxlength="20" 
       style="text-transform:uppercase" />

Example 2: input uppercase with css

input { 
    text-transform: uppercase;
}

Example 3: capitalize input text html

//for angular
(input)="onInput($event)"  

onInput(event) {
    event.target.value = event.target.value.toLocaleUpperCase();
}

//for HTML
(onInput)="onInput($event)"  

onInput(event) {
    event.target.value = event.target.value.toLocaleUpperCase();
}

Example 4: input uppercase with css

<input oninput="let p = this.selectionStart; this.value = this.value.toUpperCase();this.setSelectionRange(p, p);" />

Tags:

Html Example