0 Replies Latest reply on Dec 28, 2007 9:03 AM by kitster79

    Optional Form Fields

    kitster79 Level 1
      Can anyone help me to make two of my form fields not required for submitting the form?

      I need the 'phone' and 'situation_comments' fields to be optional.

      Here is my code...

      TEMPty_mc._visible = false;
      fielderror_mc._visible = false;

      t=this;
      tfArray = ['name','email','phone','role','situation','situation_comments','equity','email_fields',' rid','email_subject'];

      submitBtn.onPress = function() {
      entry=true;
      sendLV = new LoadVars();
      for (var i = 0; i<tfArray.length; i++) {
      //check fields for entry
      if(t[tfArray ].text.length<1) {
      entry=false;
      break;
      }
      sendLV[tfArray
      ] = t[tfArray ].text;
      }
      if(entry) {
      //send email request **CHANGE THIS PHP ADDRESS**
      sendLV.sendAndLoad(' http://as2.omni1031.com/RepSupport/contact',receiveLV,'_POST');
      }else{
      //display error message
      fieldError();
      }
      };

      receiveLV = new LoadVars();
      receiveLV.onLoad = function() {
      //do whatever: message sent successfully (thank you + info page or something)
      TEMPty_mc._visible = true;
      //in this case I've turned off all the text fields and the buttons
      for(var i=0;i<tfArray.length;i++) {
      t[tfArray]._visible = false;
      }
      submitBtn.enabled=false;
      };


      //display error message handling
      var fielderror_id:Number;

      function fieldError() {
      submitBtn._visible = false;
      submitBtn.enabled = false;
      fielderror_mc._visible = true;
      clearInterval(fielderror_id);
      fielderror_id=setInterval(this, "time", 3000);
      }

      function time() {
      clearInterval(fielderror_id);
      fielderror_mc._visible = false;
      submitBtn._visible = true;
      submitBtn.enabled = true;
      }