Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Javascript Help

  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Help

    Need assistance with writing a script in Javascript to prompt the visitor for an integer between 1 and 100 and to continue prompting until a valid number is entered.

    Any assistance would be appreciated.

    Thank You!

    Fred!

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If your purpose for asking this question related to your almost identical previous query, this post is unfounded.

    Its just bad etiquette to disregard a user's right to free will.
    hmm... ?

  • #3
    Regular Coder
    Join Date
    Feb 2004
    Location
    WA
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yup, I hate windows that dont close or message boxes that dont give up. If I dont want to enter, I will not enter.. so, dont force me to, or I will not touch that application again.
    Nobody is Perfect. I am Nobody.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    Using a form and some regular expressions would be a much more user-friendly way to validate that a user entered the correct information. I would find a recurring prompt quite annoying. In any case you could achieve the functionality you are looking for like so:

    Code:
    while (!/^[1-9](\d{1,2})?$/.test((num=prompt("Please Enter A Number from 1-100:", ""))) || num-100>0);

  • #5
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Another two pennies I'll drop into a mirage of "greater good":

    When scripting techniques are unscrupulously employed to exploit capabilities of browser components, the cumulative effect of those actions inevitably results in the removal of said features (which, by then, are relegated to bug-status), due to valid user complaints; therefore, such unethical circumventions are both futile (their counteraction will be mandated), and destructive--allowing conscientious programmers fewer tools to utilize, and end-users fewer features to potentially benefit from.

    So stop it, all of you!
    Last edited by swmr; 03-29-2004 at 10:38 PM.
    hmm... ?


  •  

    Posting Permissions

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