Posts

Showing posts with the label jquery-validate

using multiples addMethod jquery

Image
Clash Royale CLAN TAG #URR8PPP using multiples addMethod jquery I want to customize the validations of my form using the addMethod function with the jQuery validator, but when I tried to add more than one method the validator seems to look only at the first one. Here is the code: jQuery.validator.addMethod("name", function(value, element) { return this.optional(element) || /^[A-Za-zÀ-ÖØ-öø-ÿ]{2,30}$/.test(value); }, "please enter a valid name"); jQuery.validator.addMethod("surname", function(value, element) { return this.optional(element) || /^[A-Za-zÀ-ÖØ-öø-ÿ]{1,30}-?[A-Za-zÀ-ÖØ-öø-ÿ]{1,30}$/.test(value); }, "please enter a valid surname"); $("#contactform").validate({ rules: { firstname:{ required: true, name: true, minlength: 2, maxlength: 30 }, lastname:{ required: true, surname: true, minlength: 2, maxlength: 30 } ...

Error messages of jquery validate plugin is overriding jquery unobtrusive validator plugin

Error messages of jquery validate plugin is overriding jquery unobtrusive validator plugin I have a form (created by Sitecore CMS form builder) that renders the validation error messages in data attributes. The problem is that for some fields, email, for instance, it shows the validation error message from the jquery validates plugin instead of the one specified in data attributes. Here is the form <label for="fxb_00000000-0000-0000-0000-000000000000_Fields_3ea0670b-4aa8-43cf-af7a-3c4c18e2c8c2__Value" class="placeholder">Email*</label> <input id="fxb_00000000-0000-0000-0000-000000000000_Fields_3ea0670b-4aa8-43cf-af7a-3c4c18e2c8c2__Value" name="fxb.00000000-0000-0000-0000-000000000000.Fields[3ea0670b-4aa8-43cf-af7a-3c4c18e2c8c2].Value" class="form-holder__item input-validation-error" type="email" value="" maxlength="255" placeholder="Email*" data-sc-tracking="True" data-sc-...