| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- @props([
- 'length' => 6,
- ])
- <div
- x-data="{ currentNumberOfDigits: null }"
- {{
- $attributes
- ->class([
- 'fi-one-time-code-input-ctn',
- ])
- }}
- >
- @foreach (range(1, $length) as $digit)
- <div
- x-bind:class="{
- 'fi-active':
- currentNumberOfDigits !== null &&
- currentNumberOfDigits >= {{ $digit }},
- }"
- class="fi-one-time-code-input-digit-field"
- ></div>
- @endforeach
- <input
- autocomplete="one-time-code"
- inputmode="numeric"
- minlength="{{ $length }}"
- maxlength="{{ $length }}"
- pattern="\d{{ '{' . $length . '}' }}"
- type="text"
- x-data="{}"
- x-on:focus="currentNumberOfDigits = $el.value.length"
- x-on:blur="currentNumberOfDigits = null"
- x-on:input="
- $el.value = $el.value.replace(/\D/g, '')
- currentNumberOfDigits = $el.value.length
- "
- x-bind:class="{ 'fi-valid': currentNumberOfDigits >= {{ $length }} }"
- class="fi-one-time-code-input"
- />
- </div>
|