I know next to nothing about JavaScript, and I'm having problems getting a simple calculation to work. Here's what I'm trying to do. I have a signup form where users can order tickets to an event. There are only 25 seats available, and I'm keeping track of how many tickets have already been sold. I don't want the user to be able to order more tickets that we have left. I dynamically populate my JavaScript with the number of remaining tickets, and I want to check my form box on submission.
Here's my code, the form validation already works, I just can't get the calculation to work right.
Basically, if the number of tickets requested + the number of available tickets is GT 25, I want the alert to pop up. It works correctly if I try to order 1 or 2 tickets, but any other quantity throws the alert box.
Any ideas as to what could be wrong?
Hope This Helps!
ECAR
ECAR Technologies
"My work is a game, a very serious game." - M.C. Escher
Here's my code, the form validation already works, I just can't get the calculation to work right.
Code:
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if ( document.registration_form.quantity.value == "" )
{
alert ( "You must enter the Number of Tickets you want." );
valid = false;
}
[blue]if ( document.registration_form.quantity.value + 20 > "25" )
{
alert ( "There are only 5 spaces left." );
valid = false;
}[/blue]
if ( document.registration_form.os0.value == "" )
{
alert ( "You must provide your Name." );
valid = false;
}
return valid;
}
//-->
</script>
Any ideas as to what could be wrong?
Hope This Helps!
ECAR
ECAR Technologies
"My work is a game, a very serious game." - M.C. Escher