Skip navigation
Currently Being Moderated

Spry validation on Select/menu

Sep 18, 2012 12:26 AM

Hi all,

 

I have a form that has a Select/menu with 3 options, all options are text not numbers and I want the viewer to select one of these text options before trying to submit the form.

I've tried several different things but can't get it to validate on submit.

Would appreciate some advise please.

Cheers

 
Replies
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 12:33 AM   in reply to gofer

    Please post a link to your webpage so we can check.

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 1:05 AM   in reply to gofer

    Can you post your code then? Paste it here. If it's too big a code, use www.pastie.org and share the link with us.

     

    There is no way we can replicate your issue without seeing your code.

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 2:17 AM   in reply to allexx12

    Admin: Please block http://forums.adobe.com/people/allexx12

     

    He's spamming the forum

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 18, 2012 2:31 AM   in reply to Sudarshan Thiagarajan

    Sudarshan Thiagarajan wrote:

     

    Admin: Please block http://forums.adobe.com/people/allexx12

     

    He's spamming the forum

    Please use the Report button in the spam post.  (Spam messages deleted.)

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 4:43 AM   in reply to Pat Willener

    I did that. I received an error. Thought it may not have reached. Second time, when I clicked on 'Report', there was no action on page. Hence, typed the message too

     

    Thank you anyway! I wish these folks leave at the least, these forums, unspammed!

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 9:59 PM   in reply to gofer

    Add this to your page before the form code.

    <script language="JavaScript">
    <!--
      function ValidateForm(form){
    ErrorText= "";
    if ( form.select1.selectedIndex == 0 ) { alert ( "Please select one freight option." ); return false; }
      if (ErrorText= "") { form.submit() }
    }
      -->
    </script>

    I've created a new form ValidateForm and defining the form to verify if any of the index options have been selected. If the option your user selects is 0 (nothing), it will give an alert message 'Please select one frieght option'. If there is no error alert meaning if your user has selected at least one option, it will allow the user to submit your form.

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 10:22 PM   in reply to gofer

    You'll have to add else validators - this will give alerts for ALL fields you have. else if will give go through the form top down and give you one alert at a time.

     

    If you could post your full code either here or www.pastie.org, we can help you out more in detail.

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 18, 2012 11:32 PM   in reply to gofer

    You may want to use jQuery Validate here.

     

    http://docs.jquery.com/Plugins/Validation will give you lot of insight on how to achieve this. Plus, jQuery also eliminates a need for browser alert box by displaying the error messages alongside each div as plain text.

     

    This works magic!

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    3,731 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 19, 2012 12:52 AM   in reply to gofer

    See the Example - Demo & View Source to see how it can be used.

     

    A Tutorial can be seen here: http://www.jquery4u.com/forms/basic-jquery-form-validation-tutorial/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points