SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2000
    Location
    Poland
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I get an error in this function in IE 5.0, while they are run fine in NN4 and Opera5:

    function check_number(numbertotest) {
    var reg=RegExp("^[0-9]+$","");
    return reg.test(numbertotest);
    }


    Any ideas what I am doing wrong ?
    PS. The modification
    var reg=RegExp('/^[0-9]+$/',"")
    does not work either.

  2. #2
    SitePoint Enthusiast stuartd's Avatar
    Join Date
    May 2001
    Location
    Vancouver
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if this will work in IE 5.0... but I haven't heard any complains yet from my users who do.

    I tend to keep my reg vars out of the quotes.
    So mine looks like this...

    var reg=/^[0-9]+$/;

    And if you want to allow a blank entry, than just change the + to a *

    Hope that helps.

    Stuart Duncan
    www.Logiforms.com
    sales@logiforms.com

  3. #3
    SitePoint Member
    Join Date
    Dec 2000
    Location
    Poland
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you stuartd. It worked for me. I tried earlier

    var reg=RegExp(/^[0-9]+$/,"");

    but it failed too.


    Best regards,
    Chris


Bookmarks

Posting Permissions

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