chuckieDub chuckieDub - 1 year ago 117
jQuery Question

Parsley.js console errors

I thought I followed the doc exactly, but I keep getting errors.

Uncaught TypeError: Cannot read property 'fn' of undefined

That points to this function in parsely.js

$.fn.parsley = function ( option, fn ) {

And then when I click the submit button the console shows

Uncaught TypeError: Object [object Object] has no method 'parsley'

Here is my form

<script type="text/javascript" src="../GitProjects/Parsley.js/parsley.js"></script>
<script src="../jquery.js" ></script>
<link href="css/bootstrap.css" rel="stylesheet" />

<form id="demo-form" data-validate="parsley">
<label for="fullname">Full Name * :</label>
<input type="text" id="fullname" name="fullname" data-required="true" />

<label for="email">Email * :</label>
<input type="text" id="email" name="email" data-trigger="change" data-required="true" data-type="email" />

<label for="website">Website :</label>
<input type="text" id="website" name="website" data-trigger="change" data-type="url" />

<label for="message">Message (20 chars min, 200 max) :</label>
<textarea id="message" name="message" data-trigger="keyup" data-rangelength="[20,200]"></textarea>
<input type="button" value="submit" onclick="$( '#demo-form' ).parsley( 'validate' )"/>


I don't know if it matters, but I'm running this on xampp in windows as localhost.

Answer Source

Put jQuery BEFORE your parsley script. (And make sure jQuerys linking/loading correctly)

<script src="../jquery.js" ></script>
<script type="text/javascript" src="../GitProjects/Parsley.js/parsley.js"></script>