SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot ChrisOSX's Avatar
    Join Date
    May 2002
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regular Expression?

    This code isn't working properly. It should be searching for at least one occurrance of first lowercase letters, then uppercase letters, then a numeral. The alerts are just for debugging but I never see them. There are no errors reporting on the page either.

    function validate()
    {
    var strng = "The quick brown fox.";
    if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/))))
    {
    alert("Not valid.");
    }
    else {
    alert("Valid.");
    }
    }

    Sorry about the indents, couldn't figure out how to format the code in this boards editor.

  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)
    Sorry - should have answered this ages ago for you ... just didn't see it.

    use string.match(regex) - if that doesn't work - post again - i'll fix what you have.

    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
  •