Focal Point
[CLOSED]Resticting inputs

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7847081476

January 06, 2015, 01:50 PM
Fernando
[CLOSED]Resticting inputs
I have an App Studio composer page with a submit button and 2 calendars. How do I prevent a report from being submitted if the dates in the calendars are more than 1 day apart?

Note: I know how to do this in dev studio but not App Studio.

Fernando

This message has been edited. Last edited by: <Emily McAllister>,


Prod WF 8.1.04, QA WF 8.2.03, Dev WF 8.2.03
January 08, 2015, 01:55 AM
Ram Prasad E
This can be achieved using JavaScript form validation scripts.


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
December 17, 2015, 02:10 PM
Squatch
Make your calendar controls read-only so the user can't hand-edit the date (Properties section).

Make your calendar date format MDYY in the Settings section, and check the "Send unformatted value" box. Your dates will now be sent to your FEX procedure as a "MMDDYYYY" string (This may not be what your FEX is expecting, but it is for my example. You will need to tweak the following JavaScript code if you try a different date format, because it expects to rearrange the "MMDDYYYY" string temporarily into "YYYYMMDD" format for elapsed day testing).

You will need to place this code into the submit button's "Click" event (Properties event settings):

//Begin function form1Submit_onclick
function form1Submit_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
// TODO: Add your event handler code here

    var date1 = IbComposer_getCurrentSelection("calendar1");
    var date2 = IbComposer_getCurrentSelection("calendar2");

    if (date1 == "" && date2 == "") {
        alert("Please select at least one date range");
        event.stopImmediatePropagation();
        return;
    }
    var bmdyy = IbComposer_getCurrentSelection("calendar1");
    var emdyy = IbComposer_getCurrentSelection("calendar2");
    if ((bmdyy != "" && emdyy == "") || (bmdyy == "" && emdyy != "")) {
        alert("Incomplete date range");
        event.stopImmediatePropagation();
        return;
    } else {
        var byymd = bmdyy.toString().substr(4,4) + bmdyy.toString().substr(0,4);
        var eyymd = emdyy.toString().substr(4,4) + emdyy.toString().substr(0,4);
        if (eyymd < byymd) {
            alert("Start date cannot be greater than end date");
            event.stopImmediatePropagation();
            return;
        } else {
            if (eyymd - byymd > 1) {
                alert("Dates cannot be more than 1 day apart");
                event.stopImmediatePropagation();
                return;
            }
        }
    }
}
//End function form1Submit_onclick



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
December 18, 2015, 06:30 AM
George Patton
quote:
Make your calendar controls read-only so the user can't hand-edit the date (Properties section).

Brilliant !! Something new to learn every day. Smiler


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP