I have looked through this for about a day and have not been able to find out how or why this is happening... or a way around it for that matter. Here is what I'm trying to do. I have a form that has a text box and a submit button. The user types in how many credits they want to bet on whatever they are interested in, and then once the button is hit, Javascript kicks in and checks to make sure its only numbers in there and also that they have enough credits available before it actually goes in and processes the bet.
This is what is happening... if I had 10,000 credits available, the max it would allow me to bet is 1,000 credits (seems to cut off one number on the end). So, lets say I put in 5000 into form.bet.value field. It would confirm that I want to bet that much, then if I click OK it would give me an alert saying I don't have enough credits available when, in fact, I do. Now to test the values of the two variables, I actually called the variables in the alert box and the right number of credits is coming up and the correct bet amount is coming up. But still, even though credits equal 10,000 and the bet equals 5,000, the above function of form.bet.value<=form.credits.value is returning false! This doesn't make any sense! I've double checked everything it seems but still Javascript is telling me that 5,000 is not less than 10,000... If I put in a 1,000 credit bet though it will go through and forward me to the new location, but thats the most it will take! I've hit a brick wall here, anyone have any ideas?
| Code: |
|
<SCRIPT LANGUAGE="JavaScript"> function testResults (form) { TestVar = isNumberString (form.bet.value); if (TestVar == 1) { var answer = confirm ("You wish to bet " + form.bet.value + " credits. Is this correct?"); if (answer) { if (form.bet.value <= form.credits.value) window.location=(new_url...works fine); else alert("You don't have enough credits to bet that!"); } } else alert ("Please enter only numeric characters."); } //This is just to confirm its only numbers... works fine function isNumberString (InString) { if(InString.length==0) return (false); var RefString="1234567890"; for (Count=0; Count < InString.length; Count++) { TempChar= InString.substring (Count, Count+1); if (RefString.indexOf (TempChar, 0)==-1) return (false); } return (true); } </SCRIPT> |
This is what is happening... if I had 10,000 credits available, the max it would allow me to bet is 1,000 credits (seems to cut off one number on the end). So, lets say I put in 5000 into form.bet.value field. It would confirm that I want to bet that much, then if I click OK it would give me an alert saying I don't have enough credits available when, in fact, I do. Now to test the values of the two variables, I actually called the variables in the alert box and the right number of credits is coming up and the correct bet amount is coming up. But still, even though credits equal 10,000 and the bet equals 5,000, the above function of form.bet.value<=form.credits.value is returning false! This doesn't make any sense! I've double checked everything it seems but still Javascript is telling me that 5,000 is not less than 10,000... If I put in a 1,000 credit bet though it will go through and forward me to the new location, but thats the most it will take! I've hit a brick wall here, anyone have any ideas?
