How to make TextInput to allow only numbers without using numeric()

Currently when using TextInput::numeric(), the input gonna be type="number"
TextInput::make('zipcode__c')
->label('ZIP Code ')
->minLength(4)
->maxLength(10)
->numeric()
TextInput::make('zipcode__c')
->label('ZIP Code ')
->minLength(4)
->maxLength(10)
->numeric()
By using numeric the minLength and maxLength no longer works. And it also allows decimal values.
2 Replies
Bruno Pereira
Bruno Pereira4mo ago
You could use a regex validation like so /^[0-9]*$/ to only accept digits.
Want results from more Discord servers?
Add your server