Reply
windows.prompt Valiation
Old 04-08-2008, 04:49 AM windows.prompt Valiation
Novice Talker

Posts: 10
Hi

Is there any way to be able to validate windows.prompt so a user can answer a range of answers avaliable ?

windows.prompt("What is your favourite fruit ? ")

Answers avaliable
  1. apple
  2. cherries
  3. lemons
  4. bananas
  5. mangos
  6. oranges
and if the user doesnt answer any one of them fruits alert the user

Cheers

Ron007
ron007 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-08-2008, 06:58 AM Re: windows.prompt Valiation
tripy's Avatar
Fetchez la vache!

Posts: 1,819
Name: Thierry
Location: In the void
Nope.
Windows.prompt can only present a text field with the ok/cancel buttons.
You cannot present a drop down from them.

You have to create your popup in html for that.
But the popup blockers, and the fact that a window.prompt() freezes the javascript until the user input (which will not be the case with a popup) make it a complicated workaround.

I'd suggest you that you avoid javascript for that, and design your page to let the user make this choice in a form.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 04-08-2008, 07:46 AM Re: windows.prompt Valiation
Novice Talker

Posts: 10
i want to make the user to only be able to type them fruits in if any thing else is typed in i want an alert message that say you can only type the following fruits in

Ron007
ron007 is offline
Reply With Quote
View Public Profile
 
Old 04-08-2008, 09:23 AM Re: windows.prompt Valiation
Experienced Talker

Posts: 47
Like this?

Code:
<script type="text/javascript">
    if (prompt ('enter fruit') == 'apple')
    {
        alert ('you picked a valid fruit');
    } else {
        alert ('you picked an invalid fruit');
    }
  </script>
CrazeDizzleD is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to windows.prompt Valiation
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11530 seconds with 13 queries