View Full Version : javascript null NaN

01-20-2006, 07:39 AM
Ok i am trying to write a javascript function that will allow a user to type in an a srt file which is used for having subtitles show up in encoding an srt file consists of data such as:

1 //Order text is to appear this is first
00:00:57,500 --> 00:01:00,900 //Time that the text should appear during
En el mundo solo quedó un Clan //Text to appear
en un abrir y cerrar de ojos. //text to appear
//Blank space to mark new text entry
2 //order this appears 2nd
00:01:03,608 --> 00:01:07,700 //Time that text appears
Lucian, el más temido y despiadado lider //text to appear
que jamás hubo regido El Clan de Los Lycans...//text to appear

ok so what i need is to find out when im dealing with a number or text
so i just need to know what value is passed by something like this

var num;
var string="Hello";
if(num== // i want to check for null when string is text parseInt passes
//do this // not a number but some sort of null character or something
if(num) // what is it?
//do this

Philip M
01-20-2006, 09:06 AM
var num;
var string= "77 Hello";
num=parseInt(string); // num =77 as a number found at beginning of string
alert (num);
string = "Hello 77"
num = parseInt(string); // num returns isNaN as a non-numercic character found before a number
alert (num);
if (isNan(num)) { // do something.......
if (!isNaN (num)) { //do something else ......

Is this what you want?