parsley.js

parsley.js telephone digits input validating with spaces

旧城冷巷雨未停 提交于 2020-01-02 03:51:29
问题 I have an input for telephone number. I would like to write this format: 0175 6565 6262 (with spaces). But if write with " " spaces so get error and I write without spaces so get not error. Here my HTML Input: <input type="text" data-parsley-minlength="6" data-parsley-minlength-message="minlength six number" data-parsley-type="digits" data-parsley-type-message="only numbers" class="input_text" value=""> Hope someone can help me? 回答1: That's a great answer, but it's a bit too narrow for my

Can Parsley.js work without form element?

余生长醉 提交于 2020-01-02 02:54:07
问题 <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? 回答1: Parsley just cannot validate the text inside a div / span element. But you could perfectly validate an

Regex to validate string for having three non white-space characters

拥有回忆 提交于 2019-12-31 05:16:27
问题 I am using parsley js for validating input and I am using the data-parsley-pattern which allows me to pass in regular expression. I am trying to validate the string to make sure it contains AT LEAST three non white space characters. Below is strings that should be invalid or valid. valid: 1 2 b invalid: 1 b [space] valid: 3x c 1 3n invalid: 1 b [space] = is just a white space, only used it in that example because it was at the end of the string, in all the other examples, the spaces between

Control of the submission for a form

依然范特西╮ 提交于 2019-12-25 18:56:16
问题 I'm still struggling with the same problem about Parsley and semi validation. I have a form with 2 categories of fields "Contact information" (17 fields) "Company information" (5 fields) The Contact information fields are mandatory. For The "Company information fields", the user must answer only if he has a company. So one radio button named "jform[company]" allows to answer to the question "Do you have a company". If the answer is "No" - I want to apply a Semi validation (just Contact

Parsley JS - Custom error message %s format

故事扮演 提交于 2019-12-24 20:59:00
问题 I'm trying to validate a YYYY-MM-DD date with the following code (parsley plugin), but i wish to show an error message with the %s value in DD/MM/YYYY format. Is there a way to do that? Thx! <div class='input-group date' id='datetimepicker'> <input type='text' name="contact-date" id="contact-date" data-parsley-mindate="2000-01-01" /> </div> <script> window.ParsleyValidator .addValidator('mindate', function (value, requirement) { // is valid date? var timestamp = Date.parse(value), minTs =

Parsley JS Add Error/Success Class to Parent

本小妞迷上赌 提交于 2019-12-23 14:45:49
问题 I'm using Parsley JS (http://parsleyjs.org/) for form validation. The default behavior for errors is to add a class of parsley-error to each invalid input. However, I'd like to change up the default behavior and add the error class to the parent of the input - specifically on the form-group element. The basic HTML <form class="js-contact-form"> <!-- this field is just required, it would be validated on form submit --> <div class="form-group"> <label for="fullname">Full Name * :</label> <input

Erroneous placement of error message span with Parsley 2.x and Bootstrap 3

ぃ、小莉子 提交于 2019-12-22 06:37:36
问题 I'm trying to add Parsley validation to a set of radio buttons contained within a Bootstrap 3 btn-group. The issue is that the error wrapper that parsley injects (in my case set to a span) is appearing in between the two options (which are contained within a label) rather that outside the btn-group div. This is illustrated in the sample below: <div class="form-group"> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default"><input type="radio" name="BuyAgain" value="True"

parsley js - conditional required if checkbox checked

坚强是说给别人听的谎言 提交于 2019-12-22 05:15:30
问题 Is there an easy way with parsleyjs to make a field required depending on another field? See my js fiddle here http://jsfiddle.net/marksteggles/wbhLq0t4/1/ <form data-parsley-validate="true"> <div class="form-group"> <label> <input name="request_signature" type="checkbox" />Require signature</label> <div class="request_signature_fields"> <textarea class="form-control required" name="signature_reason" rows="3"></textarea> </div> </div> <input class="btn btn-success" name="commit" type="submit"

Parsley custom error message doesn't work

橙三吉。 提交于 2019-12-21 07:34:59
问题 I have the following input field: <input id="name" name="real_name" type="text" placeholder="ie. Your full name or company name" class="form-control input-lg parsley-validated" data-required="true" parsley-error-message="Please insert your name" > However, when I press my submit button, I only get the standard This value is required. message. Can anyone tell me why? 回答1: Try this attribute instead of 'parsley-error-message': data-required-message="Please insert your name" It's not a custom

How to use ParsleyJS 2.* using javascript and not data attributes

巧了我就是萌 提交于 2019-12-20 04:14:38
问题 Looking in the docs they only offer examples with data attributes, I need to write a different js file for a form and do something like: $('#myform').parsley(options); I want to know the available methods in options, and apply validators to inputs and then print custom messages. It is possible? 回答1: Yes, just use the camel case equivalent. See also the defaults $('#myform').parsley({errorClass: 'oups'}); Some javascript methods are in the documentation, others you have to look in the source.