A little math problem

# Thread: A little math problem

1. Senior Member
Join Date
Dec 1969
Posts
213

## A little math problem

I mam having a little issue with an ASP check scrupt I wrote. In the script I wrote a check to see if someone input a number less then "0". But if someone does enter say "-2" the check script does not do what it is supsed to. Can anyone see what is going on?<BR><BR>Code:<BR>&#060;%if istrength &#060;= "-1" or idefense &#060;= "-1" or iagility &#060;= "-1" or ilife &#060;= "-1" or iintel &#060;= "-1" or iki &#060;= "-1" then<BR>transformed = "not allowed"<BR>response.write "&#060;p&#062;Sorry you can&#039;t have a number less then Zero(0) to add to your stats&#060;/p&#062;"<BR>else<BR>end if%&#062;<BR><BR>NOte: all the Ixxx varibles are defined at an eriry time to retrive the info from the form. I know they are doing that right because latter on in the script where they are used works fine.

2. Senior Member
Join Date
Dec 1969
Posts
213

## RE: A little math problem

Sorry to waste space like taht but i just found the error. A little bit down in the script it was auto-redefining the "transformed" varable.

3. Senior Member
Join Date
Dec 1969
Posts
549

## You're comparing with a string

You need to compare with a number:<BR><BR>&#060;%if istrength &#060;= -1 or idefense &#060;= -1 or iagility &#060;= -1 or ilife &#060;= -1 or iintel &#060;= -1 or iki &#060;= -1 then<BR>transformed = "not allowed"<BR>response.write "&#060;p&#062;Sorry you can&#039;t have a number less then Zero(0) to add to your stats&#060;/p&#062;"<BR>else<BR>end if%&#062;<BR><BR>Also, if you know Javascript or fancy learning a little, it&#039;s better to do this in client-side code rather than ASP.

4. Senior Member
Join Date
Dec 1969
Posts
220