-3

I want to take multiple user inputs from user in a single prompt box. How can this be possible?

3 Answers3

1

In not possible in native browser behavior. You need use custom library for creating modal element. For example you can use jQuery UI

an_parubets
  • 589
  • 7
  • 15
1

The only way to do it would be to have a common separator that you split on. For instance, for the delimiter ~, you could do this:

const inputs = prompt("Enter your inputs separated by a tilde ~").split("~");

console.log(inputs);

This is not a good way to obtain multiple inputs due to the fact that the user may make a mistake when entering their data. A much better way would be to make your own custom modal with multiple areas to input data, or simply do use many sequential prompts. But no, aside from this method, there's no way to get multiple user inputs in a single, browser default prompt box.

Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
0

It is only possible by asking user to provide multiple data with delimeters e.g. input1 input2 input1,input2

and you can describe the format in prompt box message.

Tuhin Das
  • 481
  • 2
  • 11