locked
Field Validators Not Allowing Spaces RRS feed

  • Question

  • User-430413477 posted
    Using the Field Validators in the toolbox for Visual Studio 2005 / ASP.NET 2.0, is there a way to NOT allow spaces in a textbox?
    Monday, October 30, 2006 9:10 AM

Answers

  • User1520651454 posted

    use a regular expression validator instead.  Use a Regex like this:

    ^[a-zA-Z0-9]+$

    that particular pattern matches any alpha-numeric word with no spaces in it.

    MATCHES: 10a|||ABC|||A3fg

    NON MATCHES: 45.3|||this or that|||$23

    hth,

    mcm

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 30, 2006 3:13 PM