Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Date validation and stop processing
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Date validation and stop processing
 Login/Join
 
Gold member
posted
I’m using App Studio – HTML Composer with GUI. Within my page I have two calendar controls and a submit button. My goal is to perform a date validation and then stop processing in the event of a validation error. Using JavaScript I was able to do the date validation and throw an alert, but the form is still processing. Is there a way to prevent the submission of the form? I tried using ‘return false’ but that didn’t work. I have a few workarounds I can do, such as using JavaScript to submit the reports instead of the GUI, or I could hide the reports on a date validation error, but hopefully there is an easier way. Thanks!

This message has been edited. Last edited by: Joel Elscott,


WebFOCUS 8.2.03
z/OS
 
Posts: 66 | Registered: May 20, 2013Reply With QuoteReport This Post
Master
posted Hide Post
function form1Submit_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;

    if (dates_are_okay) {
       ...
    } else {
        // Dates are bad
        event.stopImmediatePropagation();
        return;
    }

}


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Reply With QuoteReport This Post
Member
posted Hide Post
Yes it can be done.
Write a function named eg. onValidate()

function onValidate()
{
if(your validation is true)
{
return(0); //it will redirect to run the procedure
}
else
{
return(2); //it will stops the report execution
}
}

This function should be called in the Tasks & Animations by creating a new Requests/Actions => "Javascript Call", Target Type => JavaScript Function, Function Name => onValidate

Followed by this request your procedure should be added next in Requests/Actions.

Thanks
Subbu


WebFOCUS 8.6
Windows, All Outputs
 
Posts: 9 | Registered: September 25, 2014Reply With QuoteReport This Post
Gold member
posted Hide Post
@subbu_088 - this worked perfectly! Thank you! This is the first time I've seen "return(2)" being used, but that's exactly what I needed.

@Squatch - Thank you for the suggestion, but unfortunately I couldn't get event.stopImmediatePropagation to work correctly. It stopped the JavaScript from processing, but then I couldn't get it restarted again when I fixed the date and resubmitted the form. Using Firebug I see that stopImmediatePropagation was an unknown function.


WebFOCUS 8.2.03
z/OS
 
Posts: 66 | Registered: May 20, 2013Reply With QuoteReport This Post
Master
posted Hide Post
quote:

@Squatch - Thank you for the suggestion, but unfortunately I couldn't get event.stopImmediatePropagation to work correctly. It stopped the JavaScript from processing, but then I couldn't get it restarted again when I fixed the date and resubmitted the form. Using Firebug I see that stopImmediatePropagation was an unknown function.

It will be unknown if you don't have "event" declared in your function:

function form1Submit_onclick(event) {

Actually, it doesn't have to be "event"... it could be "e" or whatever else you want to call it. You just need to declare something so JavaScript can fill it with data and functions related to whatever the user clicked on.

So if you declare it as "e" in your function, you would call it like this:

e.stopImmediatePropagation();

You already have another solution, so I'm posting this in case anyone else wants to try it. It works fine for me.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Reply With QuoteReport This Post
Gold member
posted Hide Post
@Squatch - Thanks again, the solution you mentioned did fix the unknown function error I was receiving. However it still won't let resubmit the form/submit button after I correct the date. It's like it stops everything on the page I can't do anything after I punch in a bad date. I do have another solution though, so I will definitely keep this in mind for in the future.


WebFOCUS 8.2.03
z/OS
 
Posts: 66 | Registered: May 20, 2013Reply With QuoteReport This Post
Master
posted Hide Post
quote:
Originally posted by Joel Elscott:
However it still won't let resubmit the form/submit button after I correct the date.

Try stopPropagation() instead of stopImmediatePropagation().


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Date validation and stop processing

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.