Form validation example in applescript

Is there a form validation example in AppleScriptObjC ? I tried searching the forums but didn’t find any yet.
Basically I want the form validation script to go through all the required fields(text boxes/areas, checkboxes, dropdowns etc) in a form and alert the user if he hasn’t filled the required fields. Being from a web development background I know how to approach this in Javascript , but I’m still finding my feet when it comes to ASOC.

Here is a Pseudo-Code I have so far:

property aTextbox : missing value  # (  Tag number "101" )
property aDropDown : missing value #(  Tag number "102" )
property aTextarea : missing value # (  Tag number "103" )

set tagList to { "101","102","103"}
set validated  to validateForm(tagList) of me

on validateForm(tagList)
   repeat with theTag in tagList
      if  theTag's type() is equal to "Textbox" then
       # Check if the Textbox is empty and change the field's border color to red to draw user's attention 

      else if theTag's type()  is equal to "Dropdown" then

     # Check if the Dropdown value says "Select"  and change the border color to red to draw user's attention

     else if theTag's type()  is equal to "Textarea" then

     # Check if the Textarea is empty and change the field's border color to red to draw user's attention 

     end if
     # Finally return true or false 
     return validated
   end repeat
   
end validateForm

BTW, type() is just something that I have used to make my point clear. I hope there is a way to find the input type based on the tag number

There are a few issues here.

There’s the issue of validation – validating what is entered – and that is normally handled via things like number and date formatters, or custom formatters and sometimes control delegate methods. The idea is to validate a field before a person moves to the next one if possible.

Then there’s the issue of checking whether anything has been entered at all, and how you do that depends a bit on what’s involved. In some cases it can be handled by binding the enabled property of the final button to entered values, and other times you have to check each field in turn in code, after the button is pressed.

Finally, there’s the issue of how to flag problems, and this gets into the realm of following established UI conventions. The choices are generally an error sheet appearing over the window, or the use of the red NSInvalidDataFreestandingTemplate arrow and optional extra explanation, and making the problematic field first responder.

@shane:
My requirements are very simple fortunately. I just have to validate required textfields(empty or not) and dropdowns and bring user’s attention to them . I want to use the red NSInvalidDataFreestandingTemplate arrow you suggested and show it next to the required field. How do I go about using this? Do I have to place a hidden red arrow image next to each required field , and show it when I call my validate function? Or is it a property for each input control that can be invoked somehow?

Pretty much. How you do it depends on how you handle other things. For example, suppose you have a text field whose value is bound to a property of your script. You could bind the hidden property of the image well to the same property, with a value transformer of NSIsNotNil.