0

This is the guide page:

http://validity.thatscaptaintoyou.com/Demos/#

I was able to find the following snippet on the page that is relevant:

 <script type="text/javascript">
        $(function() { 
            $("form").validity("input:text, select");
        });
    </script>

This is my current script that I am using:

<script>
        $(document).ready(function() {
            $("form").validity(function() {
                $("#quantity")
                    .require()
                    .match("number");
            $("#community")
            .require()
            .match("number");  
            $("#name")
            .require()
            .match("number");
            }); 
            $("#dropdown").require("You must provide a selection.");

        });   
    </script>

HTML:

<form method="get" action="">
        <input type="text" id="quantity" />
        <br />
        <input type="text" id="community" />
        <br />
        <input type="text" id="name" />
        <br /><br />
                        <select id="dropdown" name="dropdown" class="dropdown">
                            <option value="0">Please Select</option>
                            <option value="1">Sample</option>
                            <option value="2">Sample 2</option>
                        </select>
                        <br />
        <input type="submit" />
    </form>

Question: How do I make an error message display when a select menu is not filled by the user? How can I integrate it in my script above? I am new to JS so this is all foreign and puzzling to me. Please advise. Thanks!

Update:

After studying my existing code it seems that for the select menu I would require a .match(). I am unsure what I can use for this..

starbucks
  • 2,926
  • 9
  • 41
  • 53

0 Answers0