|
You should read the forum FAQ/rules and one of the "How to Post..." threads. They clearly indicate that you should put you code in tags to preserve the indentation. Anything else is rude to your potential respondents.
That said, trying to validate that a number is within a certain range by using regular expressions is like trying to swat a spider with a track hoe. Simply compare it against the upper and lower limits after ascertaining that it is, indeed, a number, with one of the available JS tests.
Your particular expression range, [1-366], says that you have a valid character set including the characters representing the numbers 1-3 (that would be 1,2, and 3), plus the character representing the number, 6. A number expressed as a string with any digits other than those will fail.
JS is a weakly typed language. You still need to know, occassionally, the difference between a string representing a number, and an actual number.
|