Data Validation Functions in ActionScript

DRK 1 includes some ActionScript classes for sending and retrieving email via Flash Remoting. It also contains an EmailAddress class that represents a valid email address (its basically validates that the email address is in a valid format).

So, why am I talking about this? Because I am trying to figure out what other types of data or user input would be useful to have validation functions for?

Thus far I have thought of:

  • Email Address
  • Zip Code
  • Phone Number
  • Credit Card Number

If you can think of other useful items, post them in the comments.

23 Responses to Data Validation Functions in ActionScript

  1. Simon says:

    Date and Time.

  2. Please make sure phone number doesn’t just validate US numbers, can we have international options too? A checker to make sure text hasn’t been entered in all CAPS is useful too, if you like the data to be stored tidily!

  3. bokel says:

    Why not including a regular expression parser ? Afaik there are two implementations out there, which could be bought and redistributed by mm

  4. kevin says:

    Social Security Number

  5. Ron says:

    You are really going to have to have some form of regex parser distributed to handle the myriad of requests for things to validate against.

  6. Nik Khilnani says:

    RegEx would help a lot, esp if it was built into the player in the future…

  7. native regexp, native xpath and native namespace support. but well i guess it’s offtopic here 😉

  8. pete says:

    Some idea’s – some more usefull than others.- Date validator (both & valid domain checker- IP numbers- Password match (based on rules suchs as no less than 4 or no more than 10)- ISBN numbers… these are just based on existing REgExp functions I know exist. Granted some might not be that usefull …

  9. John says:

    Regular expressions!!!! Regular expressions!!!

  10. ColdFusion has had built in form validation for zip code and telephone number for some time now, problem is that they are for the USA only and not customisable to work outside of that country.As Nick suggests above please try to be as global & outward thinking as you can so as to not isolate other markets.

  11. tfitch says:

    Here is another vote for date validation – I just did that with a remoting call to CF in a custom validate() function for a form, but the remoting call wouldn’t return in time during the validate script. I did a work around, but I’d rather have done it natively with no remoting.

  12. Dan Zeitman says:

    Might suggest enhanced data validation routines that use user input for triggering logic events.Example:Phone and Postal Codes for foriegn countries are alphnumeric, While US Zip codes are not.Have the vaildation rules branch based on user input. If a user chooses a State, then United States get updated on for the country field, or visa versa they choose USA and only US states would be available. In addition, the data validation masks would change for Phone and Postal Code.One of the biggest problems with designing UI with validation is the fact we tend to forget about the rest of the world and thier unique differences. Validation routines need to consider that.

  13. Hey Mike,”Data validation” really needs some regex, right? ;)I mean, date could be “mm.ddd.yyyy”, “mm-ddd-yyyy”, “”, etc., and all that in multiple regions different. The same goes for time, ZIP codes, phone numbers, social security numbers, and I could go on and on. Data validation is an area where wheel should not be reinvented. Any other approach other than meta-language such as regex will be too limitating to be used as universal data validator solution.

  14. Stephen Rogers says:

    While there would be many uses for some generic AS validation routines, the only way to approach a solution is to build a RegEx engine into the player – which would likely add more heft… I’ve found that if done correctly, I can use a quick remoting call to use RegEx on the server for validation – for example, when the text field loses focus…I’d be happy to see a more robust player though – Considering the adoption rate of new players these days, I don’t think that a player size twice the size of the current version would dissuade too many users.

  15. RegEx Data Validation would be wonderful.Found these ActionScript classes for RegEx.Andy Black’s RegEx Class : Jurjan’s RegEx Class:

  16. why don’t you post your work so we can download it and use it?That would be a nice feature.Sean Paul

  17. mike chambers says:

    The DataValidation library is avaliable on DRK 3.

  18. I’m looking for actionscript to validation postal code, not sure DataValidation is the one or not.

  19. SF says:

    Data Validation Functions in ActionScriptSQL statements to block SQL injection and such

  20. mohideen says:

    In Flash 8 ActionScript how to email Validation

  21. Hi Mike says:

    Hello Mike,I am trying to redo a project for my client that some other company built a couple of years ago. This third party used a component (i think a textfield) that looks for a file named ‘com/macromedia/validation/’. I realize this came from the DevNet Resource Kit Volume 3, but apparently that Kit is not available anymore. Would it be possible at all for you to email me just that .as file (if you have it)? It would help me out a lot. Thanks.