dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Forms

  1. #1
    Member
    Join Date
    Oct 2001
    Posts
    45
    I made a form. It has a few input boxes and a submit button. How do i make it so u cant submit untill all input boxes are filled ??

  2. #2
    Senior Member
    Join Date
    Feb 2002
    Posts
    160
    Let's say the form has input text boxes: name, phone, email, feedback. On the button, put some code that will check the length and misc attributes for each unique field. If they all check out, then the temporary variable (submit) still equals 1.. if even one of them does not check out, then submit equals -1:

    on (release){
    submit = 1;
    if (!length(name)){
    submit = -1;
    }
    if (length(phone) < 7){
    submit = -1;
    }
    if (!email.length || email.indexOf("@") == -1 || email.indexOf(".")
    == -1){
    submit = -1;
    }
    if (!length(feedback)){
    submit = -1;
    }

    // CHECKS VALUE OF submit
    if (submit == 1){
    this.loadVariable(x,x);
    }
    else {
    display error message;
    }
    }

  3. #3
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food
    Posts
    3,789

    theres probably an easer way to do this...

    Code:
    function chsckSubmitStatus() {
         var n;
         textFieldNames = [
              "field_txt",
              "field1_txt",
              "field2_txt",
              "field3_txt",
              "field4_txt",
              "field5_txt",
              "field6_txt",
              "field7_txt",
              "field8_txt",
              "field9_txt"
         ];
         for (var x; x < textFieldNames.length; x++) {
              if(textFieldsNames[x] != null) {
                   n += 1;
              }
         }
         if (n == textFieldNames.length) {
              okToSubmit = true;
         } else {
              okToSubmit = false;
         }
    }
    submit_btn.onRelease = function() {
         chekSubmitStatus;
         if(okToSubmit) {
              //do something
         } else {
              //tell them that they have to fill fill out all the fields
         }
    }
    [Edit]
    replace "field_txt", "field1_txt", "field2_txt", etc. with the names of the text fields that you want to check for values...
    [Edited by gSOLO_01 on 08-27-2002 at 10:23 PM]

  4. #4
    Member
    Join Date
    Oct 2001
    Posts
    45
    Thanks. I think im gonna use the second code, but i need alittle more help. I need to know what pieces of the code to change so it works with my form.

  5. #5
    Member
    Join Date
    Oct 2001
    Posts
    45
    I Entered The Code And It Says "This Script Contians Syntax Errors. It Must Be Edited In Expert Mode". Why Does It Say That ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center