What is the best practice for an input field that takes an IP-Address?
ie: Numbers and dots.
I've initially chosen type='number'
, However, I noticed that as soon as I type a second dot .
followed by the next number, my submit button gets disabled.
ex: 123.124.4 (boom! button disabled)
Is the above due to a decimal consideration when it comes to type=number
?
<input type="number" class="input-box" placeholder="xxx.xxx.xxx.xx" autocomplete="off" />
Is there a way out of this without going with <input type='text'/>
?
In HTML, you can verify input values with a pattern. This way, you can make something with a regular expression as following :
<input required pattern="^([0-9]{1,3}\.){3}[0-9]{1,3}$">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With