Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reopening prompt box's upon entry and submission of wrong data

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm pretty new to javascript and could really use some help on this topic.
I wanted to create a function that would reopen the prompt box until the right entry was made in it. for example say i have a question like this in my prompt box:
"what is my favorite color?" now if the user chose the wrong color I would display an alert box with some message in it to try again and reopen the prompt box upon closing of the alert box. This would continue until the right answer was picked. How can accomplish this? Any help here would be greatly appreciated.
thanks
 
This should work:

function repeatingPrompt(){
var loop=true;
while (loop){
var answer=prompt('what is my favorite color?','');
if (answer=='blue'){ loop=false; }
}
}
theEclipse
eclipse_web@hotmail.com
robacarp.webjump.com
**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Yep that does the trick...It's exactly what I was looking for. Thanks much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top