Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • C civicrm-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 113
    • Merge requests 113
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CiviCRM
  • civicrm-core
  • Merge requests
  • !16495

Open
Created Feb 07, 2020 by Michael O'Toole@MikeyOwner
  • Report abuse
Report abuse

Fix implementation of jQuery.validate

  • Overview 10
  • Commits 1
  • Changes 2

Created by: mattwire

Overview

Fix implementation of jQuery validate in CiviCRM so that it actually uses the CRM settings, validates select2 fields and uses Civi/bootstrap classes for errors.

Partial from https://github.com/civicrm/civicrm-core/pull/16488

Before

jQuery validate in CiviCRM did not work with select2. In Common.js there was code to load CiviCRM specific settings but they weren't actually being loaded!

After

select2 is validated (note that the error message is currently the label - that could be improved as could the positioning of some of the error messages - that's all possible but out of scope for this PR!): image

Technical Details

If the PR involves technical details/changes/considerations which would not be manifest to a casual developer skimming the above sections, please describe the details here.

Comments

Testing

For testing you can do in the browser console on a contribution page: var validator = CRM.$('#Main').validate(); validator.settings - to show the settings that are loaded for the page. CRM.$('#Main').valid(); to check if the form is "valid" - returns true/false.

Currently this will return valid for many required fields on the form if they are empty. This is because CiviCRM is not setting them as required before creating the form - that will be fixed in https://github.com/civicrm/civicrm-core/pull/16488. So to test you have to add the class "required" to the form fields once the page has loaded: image image

This is particularly a problem for any processor that has "billing address" fields.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: github/fork/mattwire/fixjqueryvalidate