Multi-input setup for license key

I'm making an "activate license" screen with an input for the license key, the license key itself is 5 sets of 6 characters separated by dashes. I'd like to style it as a series of inputs where each segment is written, with the dashes already built in, and focus moving between the segments as you type or delete, and a paste of the license key fills the inputs and ignores the pasted dashes. Does that make sense as a method? Should I do it in one input but style it to look like many? Is there a secret third option I'm missing? How would I even implement it? I'm currently running with svelte but I feel like this would require some vanilla js dom manipulation
28 Replies
ἔρως
ἔρως4w ago
you should do in whatever way is easier for you if you want, just 1 fake input with borderless inputs works too and then you move to the next when there is too much text on one by the way, with some googling, you might find something
mic
micOP4w ago
What I really need is an existing site that does that and yoink it violently
ἔρως
ἔρως4w ago
codepen should have examples
mic
micOP4w ago
I'll keep googling see what comes up
ἔρως
ἔρως4w ago
you can try it yourself it isnt rocket science
Jochem
Jochem4w ago
your best bet is probably to look for phone number inputs or two factor inputs, those are much more common than serial numbers
ἔρως
ἔρως4w ago
phone numbers are great gor inspiration for this many use a select for the country code or a variation
Jochem
Jochem4w ago
lots of US phone numbers are split 555-555-1234 two factor is a better bet though, and you can just use the inspector to crib off those
ἔρως
ἔρως4w ago
yup, which should be easy since there isnt any magic going on
clevermissfox
clevermissfox4w ago
Keep us posted, I’m curious on what you end up with
mic
micOP4w ago
So far I've managed to do a large part of it, but for some reason I can't backspace at the 6 character mark I'll keep playing with it today and hopefully get a proper prototype going that I can share here
ἔρως
ἔρως4w ago
you can also share what you have so far, so we can see if we spot the problem
mic
micOP4w ago
I think I'm just using the wrong keycode range but I'll kepp y'all posted
ἔρως
ἔρως4w ago
alright
mic
micOP4w ago
ἔρως
ἔρως4w ago
in terms of ux, this is very confusing in terms of ui, it looks strange
mic
micOP4w ago
oh yea ignore the top input I was planning on making that a label but forgot
ἔρως
ἔρως4w ago
you can make this into a single input very easily
mic
micOP4w ago
would that be better ux? last license I entered was like microsoft office 2013 and I kinda like that the segments look separated to make reading it looking for mistakes easier
ἔρως
ἔρως4w ago
well, it would certainly look better
mic
micOP4w ago
would adding dashes between the inputs help or? cleaned up the ui a bit and now the submit button console.logs the license key
ἔρως
ἔρως4w ago
yes, and forcing uppercase and reducing the width of the inputs
mic
micOP4w ago
forcing uppercase not a bad thought but I need to check if the licensing service I'm using is uppercase only width I agree, I also set the font to monospace and it feels better as well these changes I did in my actual app tho I should upstream them to the codepen lol okay fixed
ἔρως
ἔρως3w ago
i think it looks better now
mic
micOP3w ago
Thanks, if you can think of anything else (functionality or design) I'd love to hear it
ἔρως
ἔρως3w ago
i would make the dashes bigger
clevermissfox
clevermissfox3w ago
cant you use regx in the pattern attribute to enforce the length and the dashes
mic
micOP3w ago
I'm using a regex to verify the paste, but I feel like a 36 character string is harder on the eyes to track and if you make a mistake harder to find where it is, so I really do like the 6 segments in different input fields

Did you find this page helpful?