parsley.js

Parsley JS 2.x - how do you validate hidden fields?

微笑、不失礼 提交于 2019-11-30 23:33:13
I would like to validate hidden fields, so essentially I want to remove input[type=hidden] from parsley's list of excluded form elements. I've tried explicitly setting excluded elements in parsley's options, but hidden fields are still not validated. E.g: $(element).parsley({ excluded: 'input[type=button], input[type=submit]' }); Any thoughts on how to accomplish this, or what I'm doing wrong? I'm guessing this is a bug. Take this form: <form method="post" id="myForm"> <input type="text" name="field1" value="" class="required" /> <input type="hidden" name="hiddeninput" value="" class="required

Preventing form submission after validation by parsley.js

假如想象 提交于 2019-11-30 13:25:22
问题 I have used parsley.js many times and have literally copied the code from my last use of parsley. However, every time I submit the form the page refreshes. preventDefault seems to work on my other pages and stops the page from refreshing but for some reason when I tried now it won't work. Can anyone figure out why not? <script> $(function(){ $("#register_signup").submit(function(e){ e.preventDefault(); var form = $(this); if ($('#rform').parsley( 'isValid' )){ alert('valid'); } }); }); <

Asynchronous form submission with parsley.js

岁酱吖の 提交于 2019-11-30 09:11:08
I'm trying to create a form that is validated front end using Parsley.js and submitted asynchronously. The form is called #contactForm and the submit button is #sendData, the error comes when I hit submit on an empty or invalid form. I expect to see an 'Error' alert from invalid form data but instead it just continues with the Else condition and the data is processed by contactForm.php. $(document).ready(function() { // submit data on click and check if valid $('#sendData').click(function(e) { //check if valid with parsley var valid = $('#contactForm').parsley ( 'validate' ); if ( valid ===

Parsley.js - Displaying Errors in a Specified Element

送分小仙女□ 提交于 2019-11-30 08:55:46
Using Parsley.js , is it possible to specify the element that should hold the error messages? I tried: $('#myForm').parsley({ errors: { container: { $('#errorMessages') } } }); But the error messages are still placed right after my form inputs. guillaumepotier I've added another data- attribute, data-parsley-errors-container="#element" that could allow you directly in dom to specify where the error messages will have to be displayed. More info here: http://parsleyjs.org/doc/index.html#ui-for-field Best I returned true from the function provided with container key. My HTML Element <input type=

Change the position of parsley-errors-list in parsleyjs

一曲冷凌霜 提交于 2019-11-30 03:17:15
问题 I am using parsleyjs.org to validate my forms. The plugin creates a ui.parsley-errors-list when an input has a validation error. The problem is that the .parsley-errors-list is being placed just after the form element's "input, textarea, radio etc.." breaking my layout as follows: <fieldset> <p>Checkboxs with a max</p> <label class="checkbox parsley-error"> <input name="checkbox2" type="checkbox" required="" data-parsley-maxcheck="2" data-parsley-multiple="checkbox2" data-parsley-id="5492">

Parsley.js - Displaying Errors in a Specified Element

无人久伴 提交于 2019-11-29 12:39:19
问题 Using Parsley.js, is it possible to specify the element that should hold the error messages? I tried: $('#myForm').parsley({ errors: { container: { $('#errorMessages') } } }); But the error messages are still placed right after my form inputs. 回答1: I've added another data- attribute, data-parsley-errors-container="#element" that could allow you directly in dom to specify where the error messages will have to be displayed. More info here: http://parsleyjs.org/doc/index.html#ui-for-field Best

How can I get Parsley.js to oupt 1 error for a group of radio buttons or checkboxes?

ぃ、小莉子 提交于 2019-11-29 10:20:18
It seems like ParsleyJS outputs an error for each input in an input group. With ParsleyJS 2.x, how can I use the available features to check to make sure a minimum of 1 checkbox in a group is checked and only show 1 error under the entire group of checkboxes if not? Ok, after some trial and error, I have this working. If you are validating for at least one checkbox in a group and only want to show a single error for a group of checkboxes or radio buttons, just do the following: <label for="my_input_1"><input type="checkbox" id="my_input_1" name="my_input_group"> The Label</label> <label for=

How can I dynamically add and remove form fields to be validated by Parsley.js?

随声附和 提交于 2019-11-28 23:31:07
I have a form ('#registrations') that I am validating with Parsley.js and so far it is working fine. However, I am trying to dynamically remove form fields and add new ones to Parsley validation, depending on what someone selects in a select drop down ('#manufacturer'). Here is my markup: <select name="manufacturer" id="manufacturer" parsley-required="true" data-error-message="Please select a manufacturer."> <option value="apple">Apple</option> <option value="blackberry">Blackberry</option> <option value="htc">HTC</option> <option value="huawei">Huawei</option> <option value="lg">LG</option>

Display parsley errors in bootstrap tooltip

 ̄綄美尐妖づ 提交于 2019-11-28 09:27:36
I'm using parsley 2.0.0-rc5 and want display the error messages in a bootstrap tooltip. I'm using "parsley:field:error" but the event fires before the error is displayed in error-container and I can't pick up the error. Someone an idea how I get the error message for each field? $.listen('parsley:field:error', function (e) { dataParsleyId = e.$element.attr('data-parsley-id'); errorMsg = 'Error: ' + $('#parsley-id-'+dataParsleyId).text(); e.$element.attr('data-original-title', errorMsg); e.$element.tooltip('show'); }); The Dude Guillaume Potier, the author of parsley, has added a ParsleyUI

How can I get Parsley.js to oupt 1 error for a group of radio buttons or checkboxes?

♀尐吖头ヾ 提交于 2019-11-28 03:31:52
问题 It seems like ParsleyJS outputs an error for each input in an input group. With ParsleyJS 2.x, how can I use the available features to check to make sure a minimum of 1 checkbox in a group is checked and only show 1 error under the entire group of checkboxes if not? 回答1: Ok, after some trial and error, I have this working. If you are validating for at least one checkbox in a group and only want to show a single error for a group of checkboxes or radio buttons, just do the following: <label