Skip to Content mrc logo mrc logo
  • What is m-Power?
    Overview Demos Build Process Case Studies Specs Pricing Trial
    m-Power Resources
    Overview How-To Videos Webinars & Podcasts White Papers Fact Sheets
  • What does m-Power build?
    Overview Database Front-Ends Reporting CRM Systems Business Intelligence Dashboards Inventory Management Mobile Apps ERP Enhancements Modernization Spreadsheets to the Web MS Access to the Web B2B/Web Portals Scheduling Embedded Analytics Web Forms Workflow Data Exploration Budgeting & Forecasting APIs & Web Services Db2 Web Query Alternative
    Solutions by Industry
    Overview Manufacturing Government Foodservice Software Vendors Logistics & Supply Chain Software Consultants Healthcare
  • Development Services Training Mentoring
  • Overview Partners Press Releases Careers Events Contact Blog
  • Support Home FAQ Documentation Customer Portal Enhancements Updates Roadmap Techblog
Try m-Power

m-Power Manual

Browse:

  • Home
  • Form Validation
  • Validating via JavaScript
Back to Manual

Validating via JavaScript

 

This document will explain how to create a JavaScript function for validity checking. For basic information regarding validity checking please see this document.

The purpose of this JavaScript is to check to see if the start date is less than the end date.

Note: This is a very simple example that is meant to demonstrate how to create and setup a JavaScript function. Your JavaScript function could be designed to check for your specific needs!

Using JavaScript in Maintenance Applications

The source code for the Maintenance JavaScript used in this example can be found here.

In the example provided, we check to see if field STARTDATE, from Maintenance #230 is greater than the ENDDATE field. If it is, we force the browser to return the message "Start Date is greater than End Date" and we disallow the form from submitting, allowing the user to correct their mistake. If STARTDATE is less than or equal to ENDDATE, no message will be seen and the browser will submit the form to the database.

Compile your maintenance application, then open m-Painter. Click the "Source" button" and add the code referenced above directly before the </head> tag.

Note: If you are using the Work-with Maintenance template, do not forget to switch to the "Maintain" page before going into Source view.

Note: Be sure to replace all reference of 00230 with your 5 digit application number. Also, be sure to replace references of STARTDATE & ENDDATE with your appropriate fields.

Lastly, add the following code: onsubmit="return validate_form();" to the <form> tag.

Before making changes to the form tag:

After making changes to the form tag:

When I run my application and attempt to enter invalid data, I am presented with one of the following screens:

Using JavaScript in Report Prompt pages

The source code for the Report JavaScript used in this example can be found here.

In the example provided, we check to see if field R001, from Report #230 is greater than the R002 field. If it is, we force the browser to return the message "Start Date is greater than End Date" and we disallow the form from submitting, allowing the user to correct their mistake. If R001 is less than or equal to R002, no message will be seen and the browser will submit the form to the database.

Compile your Report, then open m-Painter. Change the page drop down, to Prompt. Click the "Source" button" and add the code referenced above directly before the </head> tag.

Note: Be sure to replace all reference of 00230 with your 5 digit application number. Also, be sure to replace the pre-defined references of R001 and R002 with the correct Record Selection numbers for your scenario.

Lastly, add the following code: onsubmit="return validate_form();" to the <form> tag.

Before making changes to the Report prompt form tag:

After making changes to the Report prompt form tag:

When I run my report and enter invalid data, I am presented with one of the following screens:

Created: February 10, 2010 | Modified: December 27, 2011

Search


Browse By Category

Build Process (13)
Starting with m-Power (8)
Retrievals (10)
Reports (15)
Summaries (4)
Maintainers (17)
Graphs (8)
m-Power Data Explorer (4)
General (24)
Calculations (5)
Utilities (9)
m-Power Administration (23)
Security (11)
Freemarker (6)
m-Painter (29)
Form Validation (5)
External Objects & UDFs (12)
Deprecated Documentation (23)
Bootstrap Templates (7)

Popular Tags

m-Painter Security Excel Database mrc-Productivity Series Production Data Dictionary Email SQL Maintainers Graphs Application Properties Retrievals Summaries Admin Record Selections Graph Properties Bootstrap Templates Maintainer Dates RPG Graphing Getting Started Report Java Compiling Freemarker Tomcat Reports Parameters Dropdowns Retrieval Advanced App Properties DB2 Form Validation Prompt Screens Popular Video Administration Bar Graphs Build Process External Objects Calculations Performance

See all tags »

michaels, ross & cole, ltd. (mrc)

Privacy Policy Cookie Policy Cookie Settings Notice at Collection Do Not Sell or Share My Personal Information

mrc (US)

2001 Midwest Road
Suite 310
Oak Brook, IL 60523
630-916-0662

mrc (UK)

Mortlake Business Centre
20 Mortlake High Street
London, SW14 8JN
+44-20-335-59566


© mrc. All rights reserved.