Rick R.
Rick R.

Reputation: 179

Parsley.js minlength not firing

I've got the following code in a simple min length test with parsley.js. The form validates the 'required' parameter on the input tag but does not generate a message when a single character (below the minlength value of 6 per the parameter) is entered and form is submitted. The JS alert fires on the submit button click. Thanks for your feedback in advance!

<html>
<body>
    <form data-validate="parsley" parsley-validate>
        <input type="text" id="parsley-minlength" parsley-minlength="6" placeholder="minlength = 6" required="required" />
        <input type="submit" name="submit" id="mytestbutton" value="Submit" />
    </form>
</body>
</html>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript" src="js/parsley.js"></script> 
<script type="text/javascript">
$(function()
{
    $('#mytestbutton').submit(function()
    {
        alert('validating');
        $('#parsley-minlength').parsley('validate');
    });
});
</script>

Upvotes: 0

Views: 5388

Answers (2)

Manthan Patel
Manthan Patel

Reputation: 1852

Try this one

  <input id="password" type="password" data-parsley-minlength="6"   id="password" class="form-control"
                           placeholder="Enter password" required>

Upvotes: 1

Vitalii
Vitalii

Reputation: 1165

Try to add "data-parsley-minlength"="[6]" to your tag. Or use .addError method description here

Upvotes: 2

Related Questions