|
| 1 | +<ion-header> |
| 2 | + <ion-toolbar> |
| 3 | + <ion-title>Input - Validation Test</ion-title> |
| 4 | + </ion-toolbar> |
| 5 | +</ion-header> |
| 6 | + |
| 7 | +<ion-content class="ion-padding"> |
| 8 | + <div class="validation-info"> |
| 9 | + <h2>Screen Reader Testing Instructions:</h2> |
| 10 | + <ol> |
| 11 | + <li>Enable your screen reader (VoiceOver, NVDA, JAWS, etc.)</li> |
| 12 | + <li>Tab through the form fields</li> |
| 13 | + <li>When you tab away from an empty required field, the error should be announced immediately</li> |
| 14 | + <li>The error text should be announced BEFORE the next field is announced</li> |
| 15 | + <li>Test in Chrome, Safari, and Firefox to verify consistent behavior</li> |
| 16 | + </ol> |
| 17 | + </div> |
| 18 | + |
| 19 | + <form [formGroup]="form"> |
| 20 | + <div class="grid"> |
| 21 | + <div> |
| 22 | + <h2>Required Email Field</h2> |
| 23 | + <ion-input |
| 24 | + #emailInput |
| 25 | + id="email-input" |
| 26 | + type="email" |
| 27 | + label="Email" |
| 28 | + labelPlacement="floating" |
| 29 | + fill="outline" |
| 30 | + placeholder="Enter your email" |
| 31 | + [helperText]="fieldMetadata.email.helperText" |
| 32 | + [errorText]="fieldMetadata.email.errorText" |
| 33 | + formControlName="email" |
| 34 | + required |
| 35 | + [class.ion-touched]="isTouched('email')" |
| 36 | + [class.ion-invalid]="isInvalid('email')" |
| 37 | + [class.ion-valid]="isValid('email')" |
| 38 | + (ionBlur)="onIonBlur('email', emailInput)" |
| 39 | + (ionInput)="onIonInput('email', emailInput)" |
| 40 | + (focusout)="onFocusOut('email', emailInput)" |
| 41 | + ></ion-input> |
| 42 | + </div> |
| 43 | + |
| 44 | + <div> |
| 45 | + <h2>Required Name Field</h2> |
| 46 | + <ion-input |
| 47 | + #nameInput |
| 48 | + id="name-input" |
| 49 | + type="text" |
| 50 | + label="Full Name" |
| 51 | + labelPlacement="floating" |
| 52 | + fill="outline" |
| 53 | + placeholder="Enter your full name" |
| 54 | + [helperText]="fieldMetadata.name.helperText" |
| 55 | + [errorText]="fieldMetadata.name.errorText" |
| 56 | + formControlName="name" |
| 57 | + required |
| 58 | + [class.ion-touched]="isTouched('name')" |
| 59 | + [class.ion-invalid]="isInvalid('name')" |
| 60 | + [class.ion-valid]="isValid('name')" |
| 61 | + (ionBlur)="onIonBlur('name', nameInput)" |
| 62 | + (ionInput)="onIonInput('name', nameInput)" |
| 63 | + (focusout)="onFocusOut('name', nameInput)" |
| 64 | + ></ion-input> |
| 65 | + </div> |
| 66 | + |
| 67 | + <div> |
| 68 | + <h2>Phone Number (Pattern Validation)</h2> |
| 69 | + <ion-input |
| 70 | + #phoneInput |
| 71 | + id="phone-input" |
| 72 | + type="tel" |
| 73 | + label="Phone" |
| 74 | + labelPlacement="floating" |
| 75 | + fill="outline" |
| 76 | + placeholder="(555) 555-5555" |
| 77 | + pattern="^\(\d{3}\) \d{3}-\d{4}$" |
| 78 | + [helperText]="fieldMetadata.phone.helperText" |
| 79 | + [errorText]="fieldMetadata.phone.errorText" |
| 80 | + formControlName="phone" |
| 81 | + required |
| 82 | + [class.ion-touched]="isTouched('phone')" |
| 83 | + [class.ion-invalid]="isInvalid('phone')" |
| 84 | + [class.ion-valid]="isValid('phone')" |
| 85 | + (ionBlur)="onIonBlur('phone', phoneInput)" |
| 86 | + (ionInput)="onIonInput('phone', phoneInput)" |
| 87 | + (focusout)="onFocusOut('phone', phoneInput)" |
| 88 | + ></ion-input> |
| 89 | + </div> |
| 90 | + |
| 91 | + <div> |
| 92 | + <h2>Password (Min Length)</h2> |
| 93 | + <ion-input |
| 94 | + #passwordInput |
| 95 | + id="password-input" |
| 96 | + type="password" |
| 97 | + label="Password" |
| 98 | + labelPlacement="floating" |
| 99 | + fill="outline" |
| 100 | + placeholder="Enter password" |
| 101 | + minlength="8" |
| 102 | + [helperText]="fieldMetadata.password.helperText" |
| 103 | + [errorText]="fieldMetadata.password.errorText" |
| 104 | + formControlName="password" |
| 105 | + required |
| 106 | + [class.ion-touched]="isTouched('password')" |
| 107 | + [class.ion-invalid]="isInvalid('password')" |
| 108 | + [class.ion-valid]="isValid('password')" |
| 109 | + (ionBlur)="onIonBlur('password', passwordInput)" |
| 110 | + (ionInput)="onIonInput('password', passwordInput)" |
| 111 | + (focusout)="onFocusOut('password', passwordInput)" |
| 112 | + ></ion-input> |
| 113 | + </div> |
| 114 | + |
| 115 | + <div> |
| 116 | + <h2>Age (Number Range)</h2> |
| 117 | + <ion-input |
| 118 | + #ageInput |
| 119 | + id="age-input" |
| 120 | + type="number" |
| 121 | + label="Age" |
| 122 | + labelPlacement="floating" |
| 123 | + fill="outline" |
| 124 | + placeholder="Enter your age" |
| 125 | + min="18" |
| 126 | + max="120" |
| 127 | + [helperText]="fieldMetadata.age.helperText" |
| 128 | + [errorText]="fieldMetadata.age.errorText" |
| 129 | + formControlName="age" |
| 130 | + required |
| 131 | + [class.ion-touched]="isTouched('age')" |
| 132 | + [class.ion-invalid]="isInvalid('age')" |
| 133 | + [class.ion-valid]="isValid('age')" |
| 134 | + (ionBlur)="onIonBlur('age', ageInput)" |
| 135 | + (ionInput)="onIonInput('age', ageInput)" |
| 136 | + (focusout)="onFocusOut('age', ageInput)" |
| 137 | + ></ion-input> |
| 138 | + </div> |
| 139 | + |
| 140 | + <div> |
| 141 | + <h2>Optional Field (No Validation)</h2> |
| 142 | + <ion-input |
| 143 | + #optionalInput |
| 144 | + id="optional-input" |
| 145 | + type="text" |
| 146 | + label="Optional Info" |
| 147 | + labelPlacement="floating" |
| 148 | + fill="outline" |
| 149 | + placeholder="This field is optional" |
| 150 | + [helperText]="fieldMetadata.optional.helperText" |
| 151 | + formControlName="optional" |
| 152 | + [class.ion-touched]="isTouched('optional')" |
| 153 | + [class.ion-invalid]="isInvalid('optional')" |
| 154 | + [class.ion-valid]="isValid('optional')" |
| 155 | + (ionBlur)="onIonBlur('optional', optionalInput)" |
| 156 | + (ionInput)="onIonInput('optional', optionalInput)" |
| 157 | + (focusout)="onFocusOut('optional', optionalInput)" |
| 158 | + ></ion-input> |
| 159 | + </div> |
| 160 | + </div> |
| 161 | + </form> |
| 162 | + |
| 163 | + <div class="ion-padding"> |
| 164 | + <ion-button id="submit-btn" expand="block" [disabled]="!isFormValid()" (click)="onSubmit()">Submit Form</ion-button> |
| 165 | + <ion-button id="reset-btn" expand="block" fill="outline" (click)="onReset()">Reset Form</ion-button> |
| 166 | + </div> |
| 167 | + |
| 168 | + <!-- Hidden region for debugging screen reader announcements --> |
| 169 | + <div aria-live="polite" aria-atomic="true" class="aria-live-region" id="debug-region" #debugRegion></div> |
| 170 | +</ion-content> |
0 commit comments