SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: form box

  1. #1
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form box

    how would i make a form box only allow underscore numbers and letters to be typed in?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add a keypress event listener (or onkeypress event handler) to the field, and prevent the default event action if the character isn't one of the allowed ones.

    It's a chore to make this work in both IE and Opera/Firefox/Safari, since the two 'camps' use different event handling models, but it's fairly straightforward.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    could i please have more info on it

  4. #4
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?

  5. #5
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have decided to do it in PHP, how wouldi make it so it only registers a username if there username contains numbers, letters and underscores?

    PHP Code:
    if $username=1,2,3,4,5,6,7,8,9,0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,q,x,y,z,_



    die(
    "Usernames can only contain numbers, letters and underscores."); 




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
  •