Click to See Complete Forum and Search --> : error messages, how do I get them????


adamlaws
02-28-2003, 09:05 AM
I'm making a calculator program for my shcool work. Part of it says that I have to produce an error message when the user types in a non integer, I.E. letters. How to I get the error message saying that they have to enter a valid number,

Thanks, Adam

khalidali63
02-28-2003, 09:34 AM
use 2 javascript functions

just like this

alert(isNaN(parseInt(value)))

if the value is number you will get false

else you will get true

hope this helps

Khalid

adamlaws
03-05-2003, 03:48 AM
right. I need help again, thanks so far. How would I insert the code suggested into my code, and how would I get my calculator to show 60 digits. Thanks,

heres the link to the code,

http://www.geocities.com/thesalamanders/calculator/calculator.html

-Adam

adamlaws
03-10-2003, 08:18 AM
sorry for pushing but I really need help:confused:

-Adam

adamlaws
03-11-2003, 03:35 AM
Here ya go,

function CheckNumber(answer) {
if(answer == ".") {
Number = document.calculator.answer.value;
if(Number.indexOf(".") != -1) {
answer = "";
}
}
if(NewNumber == "yes") {
Number2 += answer;
Display(Number2);
}
else {
if(NewNumber == "blank") {
Number1 = answer;
Number2 = "";
NewNumber = "no";
}
else {
Number1 += answer;
}
Display(Number1);
}

Thanks,

-Adam

khalidali63
03-11-2003, 03:37 AM
in the above code where do you get the isNaN error at?

Khalid