SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member maxb65's Avatar
    Join Date
    Nov 2002
    Location
    Ft. Lauderdale, FL
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I validate a prompt box?

    Hi all.
    I have a prompt box:
    Code:
    var color = prompt("Please enter a color: red, blue, or green.
    Don't use capital letters or other colors.","Color");
    I need the user to choose one of the colors. How do I say "show the prompt until a color is chosen"?


    Thanks.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var color;
    while ((color != "red")&&(color != "blue")&&(color != "green")) {
      color = prompt("Please enter a color: red, blue, or green. Don't use capital letters or other colors.","Color");
    }
    tried and tested. Hope that will do ya
    Last edited by Lunchy_Munchy; Jan 19, 2003 at 12:43.

  3. #3
    SitePoint Member maxb65's Avatar
    Join Date
    Nov 2002
    Location
    Ft. Lauderdale, FL
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lunchy_Munchy:
    Thanks a lot.
    Exactly what I was looking for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •