0

I am trying to validate my bootstrap form with Parsely javascript validator. Below is the link -http://parsleyjs.org/

However there is a problem. I noticed that the validations do not work until I put data-parsley-validate into the <form> attribute. However in their tutorial, they have clearly mentioned not to use data-parsley-validate. Below is the link - http://parsleyjs.org/doc/index.html#psly-installation-javascript

My question is, how can I validate properly without using the data-parsley-validate attribute?

3
  • 2
    The tutorial states that you either add the data-parsely-validate attribute to the form, or you manually install it with your own JavaScript. Commented Apr 10, 2015 at 7:01
  • @Blender: Which means, I don't have to use $('#form').parsley(); if I use the data-parsely-validate ? Commented Apr 10, 2015 at 7:06
  • 1
    Yes, that's what the docs say. Commented Apr 10, 2015 at 7:07

1 Answer 1

1

data-parsley-validate by documentation,

Auto bind your form with Parsley validation on document load.

If you want to avoid that (auto binding your form to parsley), you manually bind your form to parsley on document load like,

$('#form').parsley();

With respect to them mentioning not to use data-parsley-validate, they're just asking you to be cautious about repeating instantiations, meaning,

if you add a data-parsley-validate to your form with id #myForm, and then you instantiate parsley manually (again) on this form using,

$("#myForm").parsley(option); //options are your custom options

it will return the automatically bound instance, and not the manually bound instance. You may use either of the methods to instantiate parsley on your form, but NOT both.

Sign up to request clarification or add additional context in comments.

1 Comment

I want to know why they mentioned not to use data-parsley-validate ? It is easy to use it, but they said not to, eventhough all of their examples are full ofthem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.