Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Parsley.js work without form element?

<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?

like image 572
Przemysław Banaszek Avatar asked Feb 19 '14 14:02

Przemysław Banaszek


1 Answers

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');

like image 74
guillaumepotier Avatar answered Sep 28 '22 00:09

guillaumepotier