SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict rwar's Avatar
    Join Date
    Sep 2001
    Location
    PF / RS / BR
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem with isNan function

    I have an event to validate a field (input type=text) which must accept only numbers in it.

    If I put, for example:
    1 => returns ok
    a1 => returns false
    1a => returns ok

    Anyone could help me? I've tested on IE and Netscape, both in version 6x.
    php? mysql? apache? That's it.

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The answer is regex.

    Code:
    if (input.value.match(/^\D+\w+){
        Return OK;
        }
    else {
        Return false;
        // Input starts with a non-anti-integer.
        }

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •