How to get the length of a field?
"TextInput::make('zip_code')
->helperText('Please enter at least 5 character and maximum 12 characters')
->reactive()
->minLength(5)
->maxLength(12)
->required()," I have this text input and I want to get its length to render another field conditionally. Is there a way to do this?
4 Replies
Use closure customization,
$get()
and strlen()
To refine Dennis answer:
->visible(fn(Closure $get, $set) => strlen($get('zip_code')) > 12)
on the field you want shown conditionally would show the field if the string length is greater than 12
Are you perhaps looking for?
#charcount-field
Thank you, guys! π
I was looking for Toeknee answer