How to check illegal characters excluding space?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Archit Gupta
    New Member
    • Jul 2010
    • 4

    How to check illegal characters excluding space?

    i tried \w but it shows error in space...what to do...

    var illegalChars = /\W/;

    if (illegalChars.t est(str))
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what is your definition of an "illegal character"?

    Comment

    • Archit Gupta
      New Member
      • Jul 2010
      • 4

      #3
      basically i want to check use of characters other than space,'(',')' n alphabets...

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        define "alphabets" (if you’re considering Unicode, that accounts for more than 10,000 characters)

        Comment

        • Archit Gupta
          New Member
          • Jul 2010
          • 4

          #5
          basically i want to check use of characters other than space n alphanumeric characters of basic english...i want this in a form validation...fo r username...

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            then your illegal characters are roughly [^\w ] (still includes underscore) or [0-9a-z ] (using the i parameter)

            Comment

            • Archit Gupta
              New Member
              • Jul 2010
              • 4

              #7
              Originally posted by Dormilich
              then your illegal characters are roughly [^\w ] (still includes underscore) or [0-9a-z ] (using the i parameter)
              yes...but [^\w] includes space. n i dont want it as an illegal character in the if statement in my first post on this thread...

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                guess why I proposed [^\w ] …

                Comment

                Working...