Loading ...
Sorry, an error occurred while loading the content.

Validate Multiple Selects

Expand Messages
  • Albert Padley
    I have a form that has 5 identical selects - one for each day of the week. An example: $fieldform- AddInput(array( TYPE = select , NAME = monday_start ,
    Message 1 of 4 , Aug 11, 2004
    • 0 Attachment
      I have a form that has 5 identical selects - one for each day of the
      week. An example:

      $fieldform->AddInput(array(
      "TYPE"=>"select",
      "NAME"=>"monday_start",
      "ID"=>"monday_start",
      "VALUE"=>"N/A",
      "SELECTED"=>"N/A",
      "SIZE"=>1,
      "OPTIONS"=>array(
      "N/A"=>"N/A",
      "4:30"=>"4:30 or earlier",
      "5:00"=>"5:00",
      "5:30"=>"5:30",
      "6:00"=>"6:00",
      "6:30"=>"6:30",
      "7:00"=>"7:00",
      "7:30"=>"7:30",
      ),
      "LABEL"=>"Start Time",
      ));

      I need to validate that at least 1 of the 5 selects has a value
      selected that is not "N/A". In other words, 4 may contain "N/A", but at
      least one has to have a time selected. Can this be done? If so, how?

      Thanks.

      Albert Padley
    • Manuel Lemos
      Hello, ... That kind of validation is very specific. You need use ValidateServerFunction and ValidateClientFunction, or maybe write a custom input plug-in
      Message 2 of 4 , Aug 11, 2004
      • 0 Attachment
        Hello,

        On 08/11/2004 05:16 PM, Albert Padley wrote:
        > I have a form that has 5 identical selects - one for each day of the
        > week. An example:
        >
        > $fieldform->AddInput(array(
        > "TYPE"=>"select",
        > "NAME"=>"monday_start",
        > "ID"=>"monday_start",
        > "VALUE"=>"N/A",
        > "SELECTED"=>"N/A",
        > "SIZE"=>1,
        > "OPTIONS"=>array(
        > "N/A"=>"N/A",
        > "4:30"=>"4:30 or earlier",
        > "5:00"=>"5:00",
        > "5:30"=>"5:30",
        > "6:00"=>"6:00",
        > "6:30"=>"6:30",
        > "7:00"=>"7:00",
        > "7:30"=>"7:30",
        > ),
        > "LABEL"=>"Start Time",
        > ));
        >
        > I need to validate that at least 1 of the 5 selects has a value
        > selected that is not "N/A". In other words, 4 may contain "N/A", but at
        > least one has to have a time selected. Can this be done? If so, how?

        That kind of validation is very specific. You need use
        ValidateServerFunction and ValidateClientFunction, or maybe write a
        custom input plug-in class that takes care of the validation and also
        the presentation. Given that your inputs are similar, this last option
        probably makes more sense, especially if you plan to reuse the same kind
        of input grouping in different forms.


        --

        Regards,
        Manuel Lemos

        PHP Classes - Free ready to use OOP components written in PHP
        http://www.phpclasses.org/

        PHP Reviews - Reviews of PHP books and other products
        http://www.phpclasses.org/reviews/

        Metastorage - Data object relational mapping layer generator
        http://www.meta-language.net/metastorage.html
      • Albert Padley
        ... Thanks for pointing out the second option. I ll take a look, but I don t think I currently have the skills to pull that off. Albert
        Message 3 of 4 , Aug 11, 2004
        • 0 Attachment
          On Aug 11, 2004, at 3:42 PM, Manuel Lemos wrote:

          > Hello,
          >
          > On 08/11/2004 05:16 PM, Albert Padley wrote:
          >> I have a form that has 5 identical selects - one for each day of the
          >> week. An example:
          >>
          >> $fieldform->AddInput(array(
          >> "TYPE"=>"select",
          >> "NAME"=>"monday_start",
          >> "ID"=>"monday_start",
          >> "VALUE"=>"N/A",
          >> "SELECTED"=>"N/A",
          >> "SIZE"=>1,
          >> "OPTIONS"=>array(
          >> "N/A"=>"N/A",
          >> "4:30"=>"4:30 or earlier",
          >> "5:00"=>"5:00",
          >> "5:30"=>"5:30",
          >> "6:00"=>"6:00",
          >> "6:30"=>"6:30",
          >> "7:00"=>"7:00",
          >> "7:30"=>"7:30",
          >> ),
          >> "LABEL"=>"Start Time",
          >> ));
          >>
          >> I need to validate that at least 1 of the 5 selects has a value
          >> selected that is not "N/A". In other words, 4 may contain "N/A", but
          >> at
          >> least one has to have a time selected. Can this be done? If so, how?
          >
          > That kind of validation is very specific. You need use
          > ValidateServerFunction and ValidateClientFunction, or maybe write a
          > custom input plug-in class that takes care of the validation and also
          > the presentation. Given that your inputs are similar, this last option
          > probably makes more sense, especially if you plan to reuse the same
          > kind
          > of input grouping in different forms.
          >
          Thanks for pointing out the second option. I'll take a look, but I
          don't think I currently have the skills to pull that off.

          Albert
        • Manuel Lemos
          Hello, ... Yes, it requires a little learning before you can create your own custom inputs. If you plan to reuse that kind of inputs, it may be worth investing
          Message 4 of 4 , Aug 11, 2004
          • 0 Attachment
            Hello,

            On 08/11/2004 07:20 PM, Albert Padley wrote:
            >>>I need to validate that at least 1 of the 5 selects has a value
            >>>selected that is not "N/A". In other words, 4 may contain "N/A", but
            >>>at
            >>>least one has to have a time selected. Can this be done? If so, how?
            >>
            >>That kind of validation is very specific. You need use
            >>ValidateServerFunction and ValidateClientFunction, or maybe write a
            >>custom input plug-in class that takes care of the validation and also
            >>the presentation. Given that your inputs are similar, this last option
            >>probably makes more sense, especially if you plan to reuse the same
            >>kind
            >>of input grouping in different forms.
            >>
            >
            > Thanks for pointing out the second option. I'll take a look, but I
            > don't think I currently have the skills to pull that off.

            Yes, it requires a little learning before you can create your own custom
            inputs. If you plan to reuse that kind of inputs, it may be worth
            investing some time on that because it will take less time to deploy
            them in multiple forms.

            OTOH, you may also find ValidateServerFunction a little limiting as it
            only passes the current field value. You need to use global variables to
            get the values of the other fields. That would be another motivation to
            invest on custom input.

            If you would like to consider it, most of the work may have already been
            done in the example custom input class for taking dates with 3 selects
            for day, month and year. What you want is very similar despite the
            context is different. You may probably adapt the custom date input class
            to implement your own input group type. Just let me know if you would
            like further help on this.

            --

            Regards,
            Manuel Lemos

            PHP Classes - Free ready to use OOP components written in PHP
            http://www.phpclasses.org/

            PHP Reviews - Reviews of PHP books and other products
            http://www.phpclasses.org/reviews/

            Metastorage - Data object relational mapping layer generator
            http://www.meta-language.net/metastorage.html
          Your message has been successfully submitted and would be delivered to recipients shortly.