DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Cross-Field Form Validation in Oracle JET

We look at how cross-field form validation is implemented using Oracle JET and how devs can inspect their JS code to fix any errors it finds.

Andrejus Baranovskis user avatar by
Andrejus Baranovskis
·
Feb. 12, 19 · Tutorial
Like (1)
Save
Tweet
Share
7.18K Views

Join the DZone community and get the full member experience.

Join For Free

JET keeps evolving and in the latest version, its toolkit provides improved support for form cross-field validation. It is much easier to implement validation than it was before. I will show it in this example.

Example of the data entry form. Validation logic:

  • Invoice Date before Payment Due Date and Payment Date.

  • Payment Due Date before Payment Date.


Example of when two fields fail validation:


JET provides a component called the validation group. The form can be wrapped by this component to identify if any validation errors are reported there. For example, when calling a JavaScript function, before proceeding with the function code, we can check if the validation group contains errors:

The input field can be assigned with a custom validator function:

Below is an example of validation function code where cross-field validation logic is implemented. In this example, we are comparing field values with other fields. If the validation rule condition is false, the validation error is thrown:

Below is an example of function code, where the validation group is checked for errors. If there are errors in the current validation group, then the errors are displayed and the first field with an error is focused in on:

Download the sample code from my GitHub repo.

Form (document)

Published at DZone with permission of Andrejus Baranovskis, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Java Development Trends 2023
  • Top Authentication Trends to Watch Out for in 2023
  • Kubernetes vs Docker: Differences Explained
  • Writing a Modern HTTP(S) Tunnel in Rust

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: