Announcement Announcement Module
Collapse
No announcement yet.
javascript form validation: select box Page Title Module
Move Remove Collapse
Search Search Module
Collapse

Advertisement Advertisement Module
Collapse

Featured Images Featured Images Module
Collapse

Mediabistro Creative Sites Mediabistro Creative Sites Module
Collapse
Latest Topics Latest Topics Module
Collapse

  • kemingMatters
    Comment on Logo design for Game Developer
    kemingMatters
    Check the EULA on your purchased graphic, I willing to bet it explicitly states that it's not to be used as a logo or as part of one. Besides there isn't a change a % and you're in the clear rule. ...
    Today, 05:47 PM
  • skribe
    Reply to Logo design for Game Developer
    skribe
    No worries, you did not "anger" anyone. But a good number of us here have done logo design, and know how much work it is to come up with great ideas and designs, and see all the time those...
    Today, 05:43 PM
  • KitchWitch
    Reply to Logo design for Game Developer
    KitchWitch
    There's a myth that changing a piece of art a certain percentage makes it yours. That is not true. If the other company feels your logo looks too much like theirs they can come after you. It also does...
    Today, 05:40 PM
  • Monroe
    Opinions needed.
    Monroe
    Hey, guys, I'm new around here. Well, I made this forum signature earlier on today, and I wanted to have other's opinions. In my opinion, it's the best graphic I've made to date.

    Thanks for...
    Today, 05:40 PM
  • PrestoArts
    Reply to Logo design for Game Developer
    PrestoArts
    The name was acquired first. The logo came much later. Not at the same time. Yikes! Sorry to anger everyone. I'm still learning what can and can't be done in the graphics world. That isn't the exact dragon...
    Today, 05:32 PM
Advertisement Advertisement Module
Collapse

Sponsors Sponsors Module
Collapse

X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • javascript form validation: select box

    i'm working with a registration form & paypal integration...

    the form is validated with javascript and uses an array of rules thusly:

    Code:
    rules.push("required,email,Please enter your email address.");
    but now i need to add a select box where the user can choose a date...i've figured out how to pass it thru to paypal; however, i'm stumped as to how to make this field required, making sure they select a date...

    is there a way?
    Monarchs Rule!

  • #2
    You should be doing this on the server side not the client side. All I need to do is turn off javascript to bypass everything you have set-up. Considering your dealing with money that doesn't seem very good.

    Comment


    • #3
      point taken ...

      i have a lengthy js file and several php files here, so i'm thinking it's been handled; although, there is a chance the programmer who wrote this app failed in his duties, but no evidence...
      Monarchs Rule!

      Comment


      • #4
        Oh… so your just writing something to check before the form has been submitted. Well that changes things. So wouldn't making sure they select a date be accomplished similar to the below:

        Code:
        rules.push("required,date,Please choose a date.");
        I'm assuming the second item in that list is either a name or id attribute of a input element – correct?

        To offer any detailed advice ethough I would need to know the library or see the functions your working with.

        Comment


        • #5
          here is my code for the select box:
          Code:
           <tr>
             <td>Workshop Date</td>
             <td>
            <select name="os0">
             <option value=""></option>
             <option value="June 22-26, 2009">June 22-26, 2009</option> 
             <option value="July 4_test">July 4_test</option>
            </select>
             </td>
           </tr>
          the name="os0" corresponds to the hidden input value i want to send to paypal, so i'm thinking i shouldn't change it...

          and, writing the rule.push with the name does work validation-wise; however, even if i select a date i get an alert...so i'm unsure what to do about that...
          Monarchs Rule!

          Comment


          • #6
            What does the js look like?

            Comment


            • #7
              umm...scary?! ...it's 689 lines

              here's my rule:

              Code:
              rules.push("required,os0,Please select the date you wish to attend.");
              Monarchs Rule!

              Comment


              • #8
                this looks like the most relevant bit:

                Code:
                    // now, validate whatever is required of the field
                    switch (requirement)
                    {
                      case "required":
                     
                        // if radio buttons or multiple checkboxes:
                        if (form[fieldName].type == undefined)
                        {
                          var oneIsChecked = false;
                          for (var j=0; j<form[fieldName].length; j++)
                          {
                            if (form[fieldName][j].checked)
                              oneIsChecked = true;
                          }
                          if (!oneIsChecked)
                          {
                            alertMessage(form[fieldName], errorMessage);
                            return false;           
                          }
                        }
                        else if (form[fieldName].type == "select-multiple")
                        {          
                          var oneIsSelected = false;
                          for (k=0; k<form[fieldName].length; k++)
                          {
                            if (form[fieldName][k].selected)
                              oneIsSelected = true;
                          }
                          // if no options have been selected, or if there ARE no options in the multi-select 
                          // dropdown, return false
                          if (!oneIsSelected || form[fieldName].length == 0)
                          {
                            alertMessage(form[fieldName], errorMessage);
                            return false;          
                          }
                        }
                but i'm not sure i should be messing with it...
                Monarchs Rule!

                Comment


                • #9
                  whelp...looks like a dropdown select box is out and radio buttons are in...it's not pretty, but it works...

                  thanks for your help and patience tZ!
                  Monarchs Rule!

                  Comment


                  • #10
                    The js is wrong.

                    Code:
                              for (k=0; k<form[fieldName].length; k++)
                              {
                                if (form[fieldName][k].selected.value && form[fieldName][k].selected.value!='')
                                  oneIsSelected = true;
                              }
                    I'm relatively certain that was the problem.

                    Comment


                    • #11
                      ahhh!...i'll have to experiment with that when i get a chance...thanks!
                      Monarchs Rule!

                      Comment

                      Mediabistro A division of Prometheus Global Media home | site map | advertising/sponsorships | careers | contact us | help courses | browse jobs | freelancers | content | member benefits | reprints & permissions terms of use | privacy policy Copyright © 2014 Mediabistro Inc. call (212) 389-2000 or email us
                      Working...
                      X