Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Want a regular expression and its usage

    Hi,
    can anyone give me the code for the following requirement:

    I have one text area. User enters anyhting including a newline character.
    using javascript regexp, I should allow only alphanumeric string including newline(\n) character in that. otherwise give an alert message.
    Help is highly appreciated.


    Thanks & Regards,
    Murthy
    annavajjhula@yahoo.com

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,244
    Thanks
    203
    Thanked 2,555 Times in 2,533 Posts
    function checkit (thetextinputbytheuser) {
    if (/[^a-zA-Z0-9\n]/.test (thetextinputbytheuser)) {
    alert ("You may only enter alphanumeric characters");
    textboxname.focus();
    return false;
    }
    }

    Be aware that this will disallow punctuation such as , ? or !

    Was this a homework assignment?
    Last edited by Philip M; 04-24-2004 at 09:12 AM.


  •  

    Posting Permissions

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