Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript null NaN

    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:
    Code:
    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";
    num=parseInt(string);
    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •