« Web, HTML, Tech Forum

prompt with 3 input fields separated by static or forward slashes that print after enter on the same line

Posted by Raven Scott

posted
updated

Forum: Web, HTML, Tech

I am trying to create a prompt that
is either separated by hard slashes or slashes appear after specified
input range, all on a single line.

i want: M/D/Y: input/input/input

not:  M:

         D:

         Y:

example:

Enter
the date M/D/Y: '12'/'12'/'1234'Ideal: the slash appears after
populating the specified range...(mm) if users enters two integers,
backslash appears(dd) if users enters two integers, backslash
appears(yyyy) user completes the range

or: the slashes are static but the input fields between are mutable, and cursor skips slashes.

so far, this seems to work, with the remaining issues being keeping the output on the same line rather than creating a newline.

m = 0
d = 0
y = 0

m = int(input(f'M/D/Y:'),'/', d = int(input('/'), y = int(input('/'))))


Report Topic

3 Replies

Sort Replies:

Reply by canto

posted
updated

you could ask the user for a pre-formatted input (e.g. 01/01/1990) and then split by / as the delimiter


var date = "01/01/1990";
date = {month: date.split("/")[0], day: date.split("/")[1], year: date.split("/")[2]};



which would yield an output of {month: '01', day: '01', year: '1990'}.

or you could style each segment in a span tag or similar (for whatever language this is) and when you reach x chars you can auto focus the next one. then join the content of the three elements with something like .join("/").


Permalink Report Reply

Reply by Raven Scott

posted

thanks! the objective is create a hard formatted prompt where the user inputs the integers into 3 different variables with a set range for each variable.

this is getting a bit of attention in python fb group, seems it's quite daunting lol


Permalink Report Reply