Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Fixed length of input text

I want to set the input length of a textbox to 9 characters only. No more, no less. Is there any way to do it? Any help would be very much appreciated. Thanks!

like image 623
Jenna Pink Avatar asked Oct 27 '25 10:10

Jenna Pink


1 Answers

With HTML5 you can use the pattern attribute to do this:

<input type="text" pattern=".{9}" required name="patternTest" title="Field must be 9 characters long" />

Demo

About pattern attribute

like image 56
3dgoo Avatar answered Oct 29 '25 01:10

3dgoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!