6 Replies Latest reply on Apr 10, 2008 12:48 PM by rafa@mediatech

    Text field user input

    rafa@mediatech Level 1
      Hello everyone:
      I have a simple text filed question...(simple for you experts). I have a project in which the user can input some info in different fields. When the user hits the "go" button, I have a behavior that makes sure there is something inside the text fields before the user can continue. If any of the fields are blank, they get prompted to fill the required fields.

      1. how can I make sure that actual text (characters) are inside the fields? cause right know, if the user just puts a space on the fields, director allows them to continue.

      2. How can I make sure that certain fields where filled correctly. For example, I want to make sure that on the email address filed, they actually used the "@" symbol as part of their input...so that not just any combination of words work. I want them to put an email address. Same question applies for the website. When they put their website, I need it to look for the ".com" or ".net" or ".org" portion of a website before they can continue. So that if any if this extensions are not part of their answered, they are not allowed to continue.

      The behavior on the "go" button I am using to check for something on the fields is as follows (should I be doing some other way???):


        • 1. Re: Text field user input
          Level 7
          You would need to do a little checking into the contents of the text
          sprite. The lingo command you want is "contains". Look it up for
          examples and syntax.

          In addition to what you are currently doing (making sure the text
          members are not blank), you would also check to see if the email address
          member contains the @ sign:

          if member("demoEmail").text contains "@" then
          • 2. Re: Text field user input
            rafa@mediatech Level 1
            That works great Mike. Thanks for your quick reply. One more question...I bet this is harder than what I think, but here goes:
            Is there a way that Director can check if the email address the user inputs is a valid email address? I guess this has to do with looking into some kind of database, I just want to know if there is such a thing used by web users and/or developers.

            By the way, here is the code with the piece of info you gave me (is there a smarter way of doing this?):
            • 3. Re: Text field user input
              Level 7
              When you say that you want to know if it is a valid email address, do
              mean that it is configured in the correct way (name@domain.ext)? Or do
              you mean is it actually an email address that works and is connected to
              a valid mailbox? If the former, then testing for the @ sign as well as
              perhaps a period will be about the easiest way to do it. You could setup
              a regular expression to make sure that the right characters are in the
              right locations, or something like that.

              If you want to know if the email address actually works, you would need
              to send an email to it, or at least contact the server and see if it is
              valid. You can use the DirectEmail xtra to do that.

              Your code is close, but a better way is to set up a series of tests and
              decide which frame to go to based on that...

              on mouseUp me

              ok=1 --assume it will be ok to continue

              --check for blank text members
              if member("demoName").text="" then ok=0
              if member("demoEmail").text="" then ok=0
              if member("demoTN").text="" then ok=0
              if member("demoCompany").text="" then ok=0
              if member("demoStreetAddress").text="" then ok=0
              if member("demoCSZ").text="" then ok=0

              --check for email address
              if not member("demoEmail") contains "@" then ok=0
              if not member("demoEmail") contains "." then ok=0

              --if it is ok, then continue...
              --if OK has been set to 0 (no) then go to wrong
              if ok then
              go "continue"
              else
              go "wrong"
              end if

              end
              • 4. Re: Text field user input
                rafa@mediatech Level 1
                Mike:
                Thanks for your help. Your version certainly looks cleaner and makes more sense. Everything works fine except the part where it checks for "@" and "." it is ignoring that part of the test...any ideas why?

                As for the xtra, thanks for pointing me in the right direction, I will let my client know we would need to buy it if he wants that level of detail.

                Rafael.
                • 5. Re: Text field user input
                  Level 7
                  Sorry... forgot the parenthasis. Should be:

                  if not (member("demoEmail") contains "@") then ok=0
                  if not (member("demoEmail") contains ".") then ok=0
                  • 6. Re: Text field user input
                    rafa@mediatech Level 1
                    Mike. This is great...thanks for your help!