Hi,
Is it possible to use a regular expression to check a textbox to ensure numbers are between 1 and 5 entered by the user. 
I tried the following which is called when the user clicks the submit button:
if ( valueRange(q.value.value < 1 or > 5) )
{
qc.value += "Please enter a number between 1 and 5\n";
}






mscreashuns posted this at 23:34—4th December 2007.
He has: 505 posts
Joined: Jul 2005
Is it just one number they are entering? (e.g. "3," "4.25839," or "8")
Or do you want to check each number in a string of numbers? (e.g. "34352," "1232.513," "32299084")
Or do you want to check the numbers amongst a string of text? (e.g. "I have 3 apples," "I have 4.25 dollars," "I have 4259 paper clips.")
If it's the first one, I would do something very simple:
if (varName>=1 && varName<=5) {...execute action
}
else {
...execute other action
}
'
For the others, the situation would require use of the split() function and I would rather wait to see your answer to code it out.
drew22299 posted this at 12:12—5th December 2007.
He has: 107 posts
Joined: Mar 2006
Actually, I just need help with the correct syntax for the following:
if ( valueRange(q.value.value < 1 or > 5) )
{
qc.value += "Please enter a number between 1 and 5\n";
}
How do you wright if value is between 1 and 5? would the above code work if I had the correct operator?
www.hotlista.co.uk
calculator posted this at 13:27—6th December 2007.
They have: 40 posts
Joined: Nov 2007
Your complicating things way to much
if(q.value < 1 || q.value > 5){
qc.value += "Please enter a number between 1 and 5\n";
}
the || is equivalent to OR, you can also use && instead of AND
Websites for Accountants