<form id="f">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input parsley-type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email" parsley-trigger="keyup">
</div>
</form>
<script>
$(function(){
$('#f').parsley('validate');
});
</script>
Instead of form element I would like to validate content in div element, is it possible?
I've been able to (ab)use the excellent Parsley validator for non-input elements like so,
Obviously, source of the value could be anything - a div, a span, etc.
Best of luck
Parsley just cannot validate the text inside a div / span element. But you could perfectly validate an input not inside a form tag, in your example you could just do
$('#exampleInputEmail1').parsley('validate');
I had a similar issue. In SharePoint 2013 (in a Visual Web Part at least) adding a form directly in the markup causes grief. SP will 'formify' it by adding a huge blob of generated markup and change the look and feel. While there is likely a way to remedy that issue, I wanted to quickly add Parsley to a table with many inputs without toying with the SP-generated form. My solution was to use jQuery $.wrap() after the UI was rendered. Works like a charm. Yes, it still uses a form element, but maybe you were avoiding a form for similar reasons. Try this JSFiddle