validate numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nussu
    New Member
    • Nov 2007
    • 23

    #1

    validate numbers

    Hi,
    How to check a number which should not start with 80 using javascript.

    Please help me

    Regards,

    Nussu
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    we may use e regExp for this ... here is an example:

    [CODE=javascript]var no = '90567';

    function no_starts_with( no, val) {
    var re = new RegExp('^' + val);

    return re.test(no);
    }

    // that would return false :) actually
    no_starts_with( no, 80);
    [/CODE]
    kind regards

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).

      This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

      MODERATOR

      Comment

      Working...