2 Replies Latest reply on Aug 11, 2009 8:36 PM by Madhav Subedi

    Validating Data... How to validate before you submit via sendData()

    rcanulla Level 1

      I can validate the data fine, but how would I check to see if it is valid before I send the data to the server?

       

      I want to validateData() then sendData()

               private function sendData(e:Event=null):void {
                    author = new VOAuthor();
                    author.contactName = name_lb.text;
                    author.email = company_lb.text;
                    author.phone = phone_lb.text;
                    author.company = company_lb.text;
                    author.comments = comments_lb.text;
      
                    contactDB.submitQuote(author);
               
               }
               private function validateData():void {
                      //(string must be two characters or longer)
                      nameValidator = new StringValidator();
                      nameValidator.source = name_lb;
                      nameValidator.property = "text";
                      nameValidator.minLength = 4;
                      
                      // Phone validator
                      phoneValidator = new PhoneNumberValidator();
                      phoneValidator.source = phone_lb;
                      phoneValidator.property = "text";
                      
                      // Email validator
                      emailValidator = new EmailValidator();    
                      emailValidator.source = email_lb;
                      emailValidator.property = "text";
               }