View Full Version : Javascript Help

03-19-2004, 03:35 AM
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!


03-19-2004, 04:20 AM
If your purpose for asking this question related to your almost identical previous query (http://codingforums.com/showthread.php?&threadid=35332), this post is unfounded.

Its just bad etiquette to disregard a user's right to free will. :rolleyes:

03-19-2004, 04:46 AM
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.

03-19-2004, 04:46 AM
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:

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

03-19-2004, 06:44 AM
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! ;)