I'm trying to implement Validate on a survey form that has just a few
basic requirements. I'm running jQuery 1.3.2 and Validate 1.5.5.
Whenever I try to run the code, however, I get an error that
"validator is undefined". I tried Googling and found only a few hits,
most saying the HTML was invalid. Checked that, corrected a few minor
errors, but still getting the error. In addition to the code below, I
tried just the basic $("#surveyForm").validate()  but it still gives
the same error. This is on a development application, so it isn't
available online yet.

Summer

~~~~SNIPPET FROM JS FILE~~~~
var validator = $("#surveyForm").validate({
        rules: {
                recommend: "required",
                howlearnedother: {
                        required: function(element) {
                        return $('#howlearned 
input[name=howlearned]:checked').val() == 0;
                        }
                },
                describeyouother: {
                        required: function(element) {
                        return $('#describeyouother input
[name=describeyouother]:checked').val() == 0;
                        }
                }
        },
        messages: {
                recommend: "Please indicate if you would recommend the SRAC 
site to
others",
                howlearnedother: "Please indicate how you learned about SRAC's
publications.",
                describeyouother: "Please indicate your industry."
        }
});

~~~SNIPPET OF HTML FORM~~~~

                <form action="?event=submitSurvey" method="post">
                        <fieldset id="surveyForm">
                                <legend>Please complete this survey to help us 
improve our
offerings:</legend>
                                <label for="recommend">What is the likelihood 
that you would
recommend the SRAC web site or its publications to your family and
friends? Choose one number below with 1 = not likely and 10 = highly
likely.</label>
                                <div id="recommend">

                                                <input name="recommend" 
type="radio" value="1" /> 1
                                                <input name="recommend" 
type="radio" value="2" /> 2
                                                <input name="recommend" 
type="radio" value="3" /> 3
                                                <input name="recommend" 
type="radio" value="4" /> 4
                                                <input name="recommend" 
type="radio" value="5" /> 5
                                                <input name="recommend" 
type="radio" value="6" /> 6
                                                <input name="recommend" 
type="radio" value="7" /> 7
                                                <input name="recommend" 
type="radio" value="8" /> 8
                                                <input name="recommend" 
type="radio" value="9" /> 9
                                                <input name="recommend" 
type="radio" value="10" /> 10
                                </div>


                                <label for="howlearned">How did you learn about 
SRAC publications?
</label>
                                <div id="howlearned">

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="1" /> Linked from another web site<br />

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="2" /> Search engine<br />

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="3" /> Professional (e.g. Fisheries/aquaculture biologists)<br /
>


                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="4" /> Extension program<br />

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="5" /> Friend<br />

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="6" /> Magazine<br />

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="7" /> Book<br />

                                                <input name="howlearned" 
type="radio" class="checksandradios"
value="0" /> Other <input id="howlearnedother" name="howlearnedother"
value="" type="text" size="30" maxlength="30" /><br />


                                </div>

                                <label for="whyvisit">Why did you visit the 
SRAC web site?</label>
                                <div id="whyvisit">

                                                <input name="whyvisit" 
type="checkbox" class="checksandradios"
value="1" /> Aquaculture producer looking for information<br />

                                                <input name="whyvisit" 
type="checkbox" class="checksandradios"
value="2" /> Educator looking for information for my classroom<br />


                                                        <div 
id="whyvisiteducator">

                                                                <select 
name="whyvisiteducator">

                                                                                
<option value="1">Middle School</option>

                                                                                
<option value="2">High School</option>

                                                                                
<option value="3">2-Year College</option>

                                                                                
<option value="4">4-Year College</option>

                                                                </select>
                                                        </div>


                                                <input name="whyvisit" 
type="checkbox" class="checksandradios"
value="3" /> Student<br />


                                                        <div 
id="whyvisitstudent">
                                                                <select 
name="whyvisitstudent">

                                                                                
<option value="1">Middle School</option>

                                                                                
<option value="2">High School</option>

                                                                                
<option value="3">2-Year College</option>


                                                                                
<option value="4">4-Year College</option>

                                                                </select>
                                                        </div>

                                                <input name="whyvisit" 
type="checkbox" class="checksandradios"
value="4" /> Individual interested in learning more about
aquaculture<br />

                                                <input name="whyvisit" 
type="checkbox" class="checksandradios"
value="0" /> Other <input id="whyvisitother" name="whyvisitother"
type="text" value="" size="30" maxlength="30" /><br />

                                </div>


                                <label for="describeyou">Which of the following 
is best described
about you?</label>
                                <div id="describeyou">

                                                <input name="describeyou" 
type="radio" class="checksandradios"
value="1" /> Private aquaculture producer<br />

                                                <input name="describeyou" 
type="radio" class="checksandradios"
value="2" /> Aquaculture industry supplier<br />

                                                <input name="describeyou" 
type="radio" class="checksandradios"
value="3" /> Professional<br />


                                                <input name="describeyou" 
type="radio" class="checksandradios"
value="4" /> Student<br />

                                                <input name="describeyou" 
type="radio" class="checksandradios"
value="5" /> Educator<br />

                                                <input name="describeyou" 
type="radio" class="checksandradios"
value="0" /> Other <input id="describeyouother"
name="describeyouother" value="" type="text" size="30" maxlength="30" /
><br />

                                </div>

                                <label for="geographicalarea">What geographical 
area do you reside?
</label>

                                <div id="geographicalarea">

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="1" checked="checked" /> United
States<br />

                                                        <div 
id="geographicalarea_us">
                                                                <select 
name="geographicalarea_us">

                                                                                
<option value="1" >Southern Region</option>

                                                                                
<option value="2" >Northeastern Region</option>

                                                                                
<option value="3" >North Central Region</option>


                                                                                
<option value="4" >Western Region</option>

                                                                                
<option value="5" >U.S. Pacific Islands</option>

                                                                </select>
                                                        </div>

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="2" /> Africa<br />

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="3" /> Asia<br />


                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="4" /> Canada<br />

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="5" /> Central or South America<br />

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="6" /> Europe<br />

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="7" /> India<br />

                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="8" /> Middle East<br />


                                                <input name="geographicalarea" 
type="radio"
class="checksandradios" value="9" /> Southeast Asia and Pacific
Islands<br />

                                </div>

                                <div id="captcha">
                                        <label for="mykey">Please type in the 
characters in the image
below.</label> <input type="text" name="mykey" id="mykey" value=""
autocomplete="off" />
                                        <img src="/CFFileServlet/_cf_captcha/
_captcha_img-8439256608937052384.png" alt="" height="50" width="200" /
>

                                </div>

                                <input type="hidden" name="SurveyID" value="0" 
/>

                                <div align="center"><input type="submit" 
name="SubmitSurvey"
id="submitButton" value="Submit Survey" /></div>
                        </fieldset>
                </form>

Reply via email to