4 Replies Latest reply on Sep 14, 2010 8:57 AM by jfb00

    multiple number validator

    jfb00 Level 3

      Hi all,

      Looks like I can use this validator

      http://livedocs.adobe.com/flex/3/langref/mx/validators/NumberValidator.html

      How can i use this for multiple form fields? I have many in my form.

      Tks!

       

      Johnny

        • 1. Re: multiple number validator
          betheflexcoder Level 2

          Hi jfb00,

           

          The Flex inbuilt validators can be used for specific form fields. But in case you want to apply them dynamically and reduce much work of adding them for each field, I would suggest this.

           

          Have a utilty class which has methods to handle your number validator/string validator etc.

           

          Have a Custom Form field or a a Custom TextInput class.

           

          In your custom textinput class i.e; extends the mx.controls.TextInput, you must have any variables which helps you to customize your validations if required. Like , you can have some properties like "type" and declare it as inspectable property. This means, you can specify the text input type in your mxml. Check for these properties value on focusout or change event of your custom textinput and handle them by calling the appropriate validator methods from your utility class.  The value returned from your method in the utility class can be taken in your textinput and handle accordingly.(like setting errorString etc).

           

           

          If not clear, let me know. I will try posting a sample coe for this. It could take some time for me to make the sample work for you.

          • 2. Re: multiple number validator
            jfb00 Level 3

            Hi,

            Thanks for your reply and help.

            I got the idea, I will try this but if you have an example that will be better.

            Regards

             

            Johnny

            • 3. Re: multiple number validator
              betheflexcoder Level 2

              You still need the sample or done with it?

              • 4. Re: multiple number validator
                jfb00 Level 3

                Please, if you can.

                Thanks

                 

                Johnny