I used the jquery-1.4.2 library and jquery.validate.js plugin to validate the simplest form I am In the top section, I have the following code:
& lt; Script type = "text / javascript" src = "script / jquery-1.4.2.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "script / jquery.validate.js" & gt; & Lt; / Script & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "css / ui-lightness / jquery-ui-1.8.2.custom.css" & gt; & Lt; / Link> & Lt; Script type = "text / javascript" src = "script / jquery-ui-1.8.2.custom.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {// Date Picker $ ('# Birthday') Date Picture ($) "$" ("# Delivery DAT"). Duplicator (); // Apply buttons to styles $ ('Input: Button'). Validate the button (); // data validation $ ("# createAnimalForm") ({Debug: true, rule: {weight: {required: true}}, message: {weight: {required} : "Please enter a numerical value for weight"}}}}};}); Create a function () {$ ("# createAnimalForm") Valid (). Form (); } & Lt; / Script & gt;
In the body section, I have defined the input and input fields to accept weight and value. The code from the body is as follows:
& lt; Form id = "createAnimalForm" & gt; & Lt; Table cellpadding = "5px" & gt; & Lt; TR & gt; & Lt; TD & gt; Weight: & lt; / TD & gt; & Lt; Td> & Lt; Input type = "text" name = "weight" id = "weight" & gt; & Gt; & Gt; & Gt; & Gt; & Amp; Nbsp; Village & lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; Td align = "left" & gt; & Lt; Input type = "button" onclick = "createclicked ();" Id = "createButton" name = "createButton" value = "create animal" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt;
When I load a page in Firefox, I get the following error in the firebug:
$ ("# createAnimalForm"). Not a valid function
I searched for something on the net, but there was no solution for this. I think I have a jquery library located in the right place, and it appears that the jquery-validation plugin is compatible with jquery-1.4.2.
Any ideas on what I am doing wrong?
Thank you, Nikhil.
When you are certifying, then you do not have the right thing to try:
Validate // data validation $ ("# createAnimalForm") ({Debug: true, rule: {weight: {expected: true}}, message: {weight: {required: "your message here" }}});then use:
if ($ ('$ createAnimalForm'). Validate (). Form ()) {...} < / Code>
Wherever you want to trigger verification.
Comments
Post a Comment