Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback on: Articles, February 15, 2001 at 12:49:21:

You are here: irt.org | About | Feedback | 2378 [ previous next ]

Feedback on:
Articles

Sent by
Russell Cottrell on February 15, 2001 at 12:49:21:

Worth:
Very worth reading

Comments:
Oops, I just sent you a letter and the script was not received. Here it is again:

Hello; I was looking for a way to tell if a variable was a number or not. It seems that there is no standard way to do this. I read your article at http://developer.irt.org/script/39.htm ("Is there a simple way to test if a variable is a number . . .") and came up with another solution, that works in IE 5.01 and NN 4.75:

<SCRIPT LANGUAGE="JavaScript">
function isitanumber(variable) {
if (variable/1 !== variable/1)
document.form.field.value = 'Error';
}
</SCRIPT>

It works with any number, integer or not. I assume it works because JavaScript doesn't know how to divide non-numbers. I used it to validate input entries into a random number generator I made.

Perhaps this will be useful . . .
--Russell Cottrell


Other feedback on 'Articles' - show all

©2018 Martin Webb