Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 10
Trades: 0
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
 
 
Register now for full access!
Old 04-08-2008, 07:58 AM Re: windows.prompt Valiation
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-08-2008, 08:46 AM Re: windows.prompt Valiation
Novice Talker

Posts: 10
Trades: 0
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, 10:23 AM Re: windows.prompt Valiation
Skilled Talker

Posts: 71
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.19139 seconds with 12 queries