Thread: Form validation

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    15
    Rep Power
    0
    I have been using JS for my form validation needs upto now but I have been noticing more and more problems with relying on this. Therefore I am now in the process of changing all this over to PHP, unfortunately I am stuck on how to check that the username field contains no spaces and that it is no longer than ten characters. Any suggestions?
  2. #2
  3. No Profile Picture
    Carpe Diem
    Guest
    Devshed Newbie (0 - 499 posts)
    function validate_username($username)
    {
    if((strlen($username)<4) &#0124; &#0124; (strlen($username)>8))
    {
    return true;
    }
    if(!ereg('^[a-zA-Z0-9]+$',$username))
    {
    return true;
    }

    }

    then use something like
    if(validate_username($username))
    {
    echo"Bad Username";
    $goback=1;
    }

    etc......

    ------------------

    Regards
    Darren
    --
    http://www.php4hosting.com/ $
    http://www.php4hosting.co.uk/
    PHP/MySQL Enabled Hosting/Dedicated Servers

Similar Threads

  1. form validation!!!
    By boskyvora in forum HTML Programming
    Replies: 5
    Last Post: February 6th, 2004, 08:45 AM
  2. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 07:40 PM
  3. dynamic JS form validation
    By rgoel in forum HTML Programming
    Replies: 2
    Last Post: January 8th, 2004, 02:44 AM
  4. Replies: 2
    Last Post: December 23rd, 2003, 05:23 AM
  5. Replies: 0
    Last Post: December 22nd, 2003, 09:02 AM

IMN logo majestic logo threadwatch logo seochat tools logo