SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: REGEX Help

  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    REGEX Help

    Hello

    I have a form, where user enter some thing. I want to block the GIBBERISH SPAMMING therefore I want to put a javascript function that will look for the 3 or 4 or 5 consonants in a row like : sjvamnl etc etc ,

    please let me know how this can be achieved via JavaScript and Regex ?
    Thanks
    Zeeshan

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Javascript is a clientside language.
    This means a user can bypass your validation by simply disabling javascript.

    You should use a serverside language for this.

  3. #3
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes u are right, and I will do both the Client Side and the Server side with the same Regex patters. So please let m know how to find consonants 3 in a row ?

  4. #4
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    someone please respond to me, I want to have a good NAME validation script.

  5. #5
    doRighteousDeeds++
    Join Date
    Aug 2006
    Location
    تركيا Turkey Türkiye
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Zeeshan,
    I don't sure if this is what you wanted:
    Code:
      
    <script type = "text/javascript"> 
    
    var str="sjvamnl";
    var re=/[bcdfghjklmnprstvyz]{3,5}/g;
    
    // alert(re.test(str)) // true
    if(re.test(str)) {
    alert("it was found");  
    alert(str.match(re));  // sjv, mnl
    alert(str.match(re)[0]); // sjv
    alert(str.match(re)[1]); // mnl
    }
    
    </script>
    http://lawrence.ecorp.net/inet/samples/regexp-intro.php
    Last edited by muazzez; Jul 26, 2008 at 13:16.
    The Time Through Ages. In the Name of Allah, Most Gracious, Most Merciful.
    1. By the Time, 2. Verily Man is in loss,
    3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy.

  6. #6
    Non-Member eautocad's Avatar
    Join Date
    Jul 2008
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change the location of your form so the spammers lose track, then make changes to it
    Last edited by r937; Jul 27, 2008 at 03:00.


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
  •