hey guys I just wanted some feedback on how you guys handle form's and
simple error checking. this is what I put together quickly this
morning for my form. but I was hoping to get some input on how to do
it better and what other options I have for validation. The project is
all AS2 and flash 8 also. Thanks in advance.


Code:

fName_input.tabEnabled = true;
lName_input.tabEnabled = true;
title_input.tabEnabled = true;
company_input.tabEnabled = true;
other_input.tabEnabled = true;


fName_input.tabIndex = 1;
lName_input.tabIndex = 2;
title_input.tabIndex = 3;
company_input.tabIndex = 4;
other_input.tabIndex = 5;

fName_input.restrict = "a-z A-Z \\- \\. \\,";
lName_input.restrict = "a-z A-Z \\- \\. \\,";

function checkFormCompletion():Void{
        
        if(fName_input.length <= 1 || lName_input.length <= 1 ||
title_input.length <= 1 || company_input.length <= 1 ||
other_input.length <= 2){
                
                _parent.nextBtn.enabled = false;
                _parent.nextBtn.gotoAndStop(1);
                _parent.nextBtn.onPress = null;
                
                
                var errorString:String = this._name + "_error";
                var errorMc:MovieClip = this._parent[errorString];
                errorMc.gotoAndStop("active"); //display error
                
                return; 
        }
        
        // if all fields complete turn on nextBtn to allow user to
move to the next step
        _parent.nextBtn.enabled = true;
        _parent.nextBtn.gotoAndStop(2);
        _parent.nextBtn.onPress = _parent.leaveHomeForm;
}

function collectHomepageFormData():Void{
        trace("DATA COLLECTED FROM HOMEPAGE FORM");
        _global.userfName = fName_input.text;
        _global.userlName = lName_input.text;
        _global.userTitle = title_input.text;
        _global.userCompany = company_input.text;
        _global.userOther = other_input.text;
        
        _global.userName = _global.userfName + " " + _global.userlName;
}

fName_input.onChanged = checkFormCompletion;
lName_input.onChanged = checkFormCompletion;
title_input.onChanged = checkFormCompletion;
company_input.onChanged = checkFormCompletion;
other_input.onChanged = checkFormCompletion;



-- 
Corban Baxter
http://www.projectx4.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to