September 1, 2009

Online Form Validation in Flash

Notice the following sample swf , There is an some limitation for all text boxes. if it exceeds it will show alert box. This sample validating string length and text format


  1. Create new Flash File (File->New or Ctrl + N) and Name it as 'formvalidation'.
  2. Create form with input fileds .and give Instance name for all text boxes 
  3. Decide the limits for each text box ( for example in this sample first text box will only accept 8 characters) 
  4. Now use the following code


    var strlen:String = txt_name.text;
    if (strlen.length>8) {
    mx.controls.Alert.show("This field only accepts Maximum 8 characters only");
    txt_name.text = strlen.substr(0, 8);
    }

    };
    //for validating string length
    txt_email.onChanged = function(textfield_txt:TextField) {

    var strlen:String = txt_email.text;
    if (strlen.length>15) {
    mx.controls.Alert.show("This field only accepts Maximum 15 characters only");
    txt_email.text = strlen.substr(0, 15);
    }

    };
    //for validating character type
    txt_phone.onChanged = function(textfield_txt:TextField) {

    if (int(txt_phone.text) == 0) {
    mx.controls.Alert.show("This field only accepts Numbers only");
    txt_phone.text = "";
    }

    };
  5. Now give ctrl+Enter to run the player.

Download Source Code From here
 

About

we are doing all kind of web / standalone applications using Flash , FMS, PHP , XML , CSS , etc. we handle all projects starting from the initial design concept through the delivery of your personalized product. Our commitment to you is comprehensive and complete-aimed at satisfying your every need. We have the experience and the expertise to get the job done.

Site Info

we Currently handling web requirements and multimedia productions and we have the capability of cutting your web , graphics and multimedia expenses to a bare minimum without sacrificing professional quality or delaying production. Our focus is on the development of smart, successful ideas and we always strive to maintain the highest . we currently using following technologies Flash 8, Flash cs3,Actionscript 2 ,Action script 3 ,Flash Media server , PHP,AMFPHP,XML ,HTML ,CSS ,Photoshop

Text

Digizone, AnnaNagar East, Chennai, TamilNadu ,India. Please view our website for further details

Flash and photoshop resources FREE Download Copyright © 2009 Community is Designed by Bie