Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript Quickie

Options
  • 20-10-2006 9:31am
    #1
    Registered Users Posts: 648 ✭✭✭


    hi

    when someone fills in a username field i dont want them to have spaces or special characters

    i found a function


    function f(o){
    o.value=o.value.toUpperCase().replace(/([^0-9A-Z])/g,"");
    }


    however this changes the letters to capitals - anyone know how i can allow upper and lower caps, no spaces or special characters?


Comments

  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    isnt it something like this?

    function f(o){
    o.value=o.value.toUpperCase().replace(/([^0-9a-zA-Z])/g,"");
    }


    incidently I would suggest you have a look at this

    http://www.massimocorner.com/validator/ - I find it one of the best form validation scripts out there


  • Registered Users Posts: 82 ✭✭skidpatches


    o.value=o.value.replace(/([^0-9A-Za-z])/g,"");


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    skidpatches is right - get rid of the toUpperCase()


  • Registered Users Posts: 648 ✭✭✭ChicoMendez


    Tnx Lads


Advertisement