1 Reply Latest reply on Mar 21, 2014 10:46 PM by Flex harUI

    Reg Exp always returning false value

    Ahmed Imran A K

      Hi,

       

      Below is my code. I want to restrict the values to only alphabets and numbers and not special char.

       

      But the below condition fails on a positive value also. Ex: ABCD, abcd, 1234. These should be acceptable.

       

      Is the reg exp wrong?

       

      private var special_char:RegExp = /^[A-Za-z0-9]*$/;

       

                                    private function validateSpecialChar(inputValue:String):Boolean {

                                              if (special_char.test(inputValue))

                                              {

                                                        valid = true;

                                              }

                                              else

                                              {

                                                        valid = false;

                                              }

                                              return valid;

                                    }

       

      Thanks,

      Imran