0
My code asks for input and prints out a color and a statement. But input could be anything, Is there a way to limit to colors?
using Scanner for input
4 Réponses
0
for example, you can use select tag with options
0
what form of color value it must be?
1. words like red, blue, green....
2. hex: #345465, #2008544, #ffa
3. rgb/rgba
4. hsl/hsla
0
Using Java:
You could just prompt for a list of colors and only check for these. Every other input could be ignored by your script.
Your prompt should be in a do..while loop till it's a correct input.
There is afaik no way to limit users input, the script have to doublecheck if it's correct or not and give hints back to the user if something wrong.
Using HTML etc:
you can use option tags
0
that seems workable, thanks