You need to call the JS function on Submit button onClick event.
onclick=validateInputs();
The function validates for, whether any value is enterd in Text box or not...
Thanks,
Ramkumar. WebFOCUS/Tableau Webfocus 8 / 7.7.02 Unix, Windows HTML/PDF/EXCEL/AHTML/XML/HTML5
January 17, 2011, 09:21 AM
Francis Mariani
Ramkumar, thanks for the example.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 17, 2011, 09:36 AM
Ramkumar - Webfous
Pleasure is mine
Thanks,
Ramkumar. WebFOCUS/Tableau Webfocus 8 / 7.7.02 Unix, Windows HTML/PDF/EXCEL/AHTML/XML/HTML5
January 17, 2011, 10:03 AM
Francis Mariani
Interestingly, in document Designing a User Interface for a Web Application With the HTML Composer 7.6.9 & Higher, section "Using JavaScript Code With HTML Composer Pages", it is stated "Although the HTML Composer is fully integrated with JavaScript, it is suggested that you do not create custom JavaScript that manipulates the HTML Composer generated controls, as WebFOCUS cannot support such custom JavaScript code. Additionally, there is no guarantee that the JavaScript code will work correctly in future releases." That's all it says about JavaScript.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 17, 2011, 12:34 PM
<JG>
quote:
HTML Composer generated controls
That's correct.
Do not hack the control, what you work on is any parameter associated with the control.
For example an input text area is a control but the value you type in is the parameter.
Applying validation to what you type in based on an onChange action is not affecting the control It's only affecting the input to the control.
January 17, 2011, 01:22 PM
Francis Mariani
But I have to add an onSubmit or onClick event handler somewhere, doesn't that "hack the control"?
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
January 17, 2011, 02:52 PM
roy
Where to acquire the example/information/books of js that works in the //Begin function button1_onclick function button1_onclick(ctrl) {
} //End function button1_onclick The GUI interface and Pure JavaScript don’t work the same
WebFOCUS 7.6 Windows, All Outputs
January 18, 2011, 12:59 AM
Ramkumar - Webfous
quote:
But I have to add an onSubmit or onClick event handler somewhere, doesn't that "hack the control"?
Francis
Thatz not kind of Hacking the Control. Thatz adding the event handler attribute to the control.
Is there any other way built internally with the HTML composer, to add validation... In the new release ????
Thanks,
Ramkumar. WebFOCUS/Tableau Webfocus 8 / 7.7.02 Unix, Windows HTML/PDF/EXCEL/AHTML/XML/HTML5
February 08, 2011, 07:56 PM
Francis Mariani
Simple form with two text boxes and a submit button. When the submit button is clicked, I want to verify that something is entered in each of the two boxes. Easy in the real world, difficult in the GUI world.
I tried the onclick event handler. GUI creates "form2Submit_onclick" function. I put my validation in there. Validation works - alerts are displayed, but the form still gets submitted.
There is no onSubmit event handler in the GUI for this submit button.
How to control this???
Why does this kind of stuff make me feel like a beginner again? Shouldn't I feel like I'm graduating to something bigger?
This message has been edited. Last edited by: Francis Mariani,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 09, 2011, 05:48 AM
Ramkumar - Webfous
function form2Submit_onclick(ctrl) {
if (document.getElementById('edit3').value == '')
{
alert('no country entered');
return;
}
if (document.getElementById('edit4').value == '')
{
alert('no seats entered');
return;
}
document.form2.submit();
}
This is the way. You can Submit the Form in the JS function, once all validations passes on.
document.form2.submit();
Doing OnSubmit inside OnClick... Thatz that.
Thanks,
Ramkumar. WebFOCUS/Tableau Webfocus 8 / 7.7.02 Unix, Windows HTML/PDF/EXCEL/AHTML/XML/HTML5
February 09, 2011, 09:29 AM
Francis Mariani
Except that this submit overrides the GUI submit which is buried somewhere in the external javascript, and who knows what this will break.
I know I can do my validation with an onclick event handler on the "fake" submit button, the question is, how do I stop the formm from being submitted? My validation function works, it alerts the errors but it doesn't stop the form from being submitted.This message has been edited. Last edited by: Francis Mariani,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 09, 2011, 10:50 AM
Lucas
Francis, Here is a quick mock up of what your asking....
<form action="somepage.asp" method="post" onsubmit="return aValdiationFunction();">
<input type="submit" name="submit" value="push my button" />
</form>
<script>
function aValdiationFunction()
{
var does_something = false;
does_something = window.confirm("do you like rabbits?");
if (does_something)
return true;
else
return false;
}
</script>
you simply perform all tests you need to perform on the form objects and if it pass the tests you return true otherwise you return false from the function.
true = the form submitting false = no submission
Let me know if you little more detailed example.
JayThis message has been edited. Last edited by: Lucas,
7.6.6 Mainframe 7.6.4 Web Focus Windows
February 09, 2011, 11:07 AM
<FreSte>
Francis,
I'm not sure if this will break something (now or in the future), but this is maybe getting close to what you want.
1: Change the form-event into onsubmit="myOnExecute(this);return false;" 2: Create function myOnExecute
function myOnExecute(ctrl) {
var _msg = checkit();
if ( _msg == "") {
OnExecute(ctrl);
}
else {
alert(_msg);
}
}
3: Create the checkit function
function checkit() {
var _str = "";
if (document.getElementById("edit3").value == "") {
_str += "no country entered" + "\n";
}
if (document.getElementById("edit4").value == "") {
_str += "no seats entered" + "\n";
}
return _str;
}
-Fred-
February 09, 2011, 11:59 AM
Francis Mariani
Thanks for the sample JavaScript. I have created hand-coded forms for years and know how to validate and control form submission.
I need to do this within a GUI-generated html form, without breaking anything.
At the moment, there is no onSubmit on the submit button because it's not a submit button but a regular button - the GUI does not create submit buttons.
14:55 - CORRECTION! It IS a form submit button. I added the onclick event handler via the GUI.This message has been edited. Last edited by: Francis Mariani,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 09, 2011, 02:23 PM
BJones
I think it's a bug within the Form generation of the GUI tool. The form tag has 'onsubmit="OnExecute(this);return false;"' on it, and really it needs to be calling another javascript function that does the OnExecute so you can add your edits around it and prevent the form from submitting. When you use the tool, if you tell it to not generate a Form it will create this type of code for you, this should work the same way.
You can go into the code and change it around to work and it seems to work fine without breaking anything, but if you are doing everything in the GUI...you shouldn't have to do this.
Bob
Prod: WebFocus/ReportCaster 7.6.10 - Self Service - Windows 2003 Server - IIS/Tomcat
Test: WebFocus/ReportCaster 7.6.10 - Self Service - Windows 2003 Server - IIS/Tomcat
Databases: MS SQL Server, Focus DB, Output: HTML, Excel 2000 and PDF
February 09, 2011, 03:22 PM
Francis Mariani
Bob,
I think you've hit the nail on the noggin!
A formless parameter screen has a submit button with a onclick event handler pointing to submitButton_OnClick(this). This function has a comment line // TODO: Add validation code here, then executes OnExecute(ctrl). THIS MAKES SENSE.
A parameter screen WITH a form has a submit button with no onclick event handler, unless I add one. The form itself has a onsubmit event handler that executes OnExecute(this). THIS DOES NOT MAKE SENSE.
Perhaps I can add the validation function call to the form onsubmit event handler, but I don't know if it will break the GUI...
Thanks for pointing this out. Case-opening time.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 10, 2011, 09:54 AM
Francis Mariani
Exhibit 1, an HTML Composer example with form validation. Please see the form onsubmit event handler. I've added a call to a validation function. I would like to validate the form and NOT SUBMIT the form if an error was found. This code does not work - it validates the form correctly but the form gets submitted regardless of error.
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 10, 2011, 10:19 AM
Francis Mariani
This type of thing needs to be documented.
"If you need to validate the form, do this: ...".
Why do I have to go through the pain of invention, I cannot be the first person to attempt this?
Thanks to FreSte...
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 10, 2011, 04:14 PM
RReeder
Bob said:
quote:
I think it's a bug within the Form generation of the GUI tool. The form tag has 'onsubmit="OnExecute(this);return false;"' on it, and really it needs to be calling another javascript function that does the OnExecute so you can add your edits around it and prevent the form from submitting. When you use the tool, if you tell it to not generate a Form it will create this type of code for you, this should work the same way.
You can go into the code and change it around to work and it seems to work fine without breaking anything, but if you are doing everything in the GUI...you shouldn't have to do this.
In 7.1.6 this is how the validation for onsubmit worked. I have several HTML pages which were using Javascript to perform field level validation which used this format for onsubmit: 'onsubmit="OnExecute(this);return false; what you would do is put your validation code in the middle of the code like this: 'onsubmit="OnExecute(this);validationscript();return false;"
When we upgraded to 7.6.10 two weeks ago however, every one of those pages failed to work. When running from the dashboard they would reset all the fields and do nothing. When working with them in Dev Studio and running to see results from Dev Studio they would not load the page properly. It would continuously act as if the browser was trying to load the page but would throw and error on page which when I traced was found to be in the composer.js file now included with the composer. this is a new file from 7.1.6.
Monday I am hoping to work with my server guy and run more accurate traces and see why none of my validations will work. I now can't get anything to work with composer and had to remove them for now and let the server handle validation instead of the client. Client is not only more efficient for the user but also is better on the server performance and load tolerance.
I agree that there should be better ways to create validations with WebFOCUS. Most 4th Generation Languages have some validation capabilities. Even Adobe forms allows for number, length, date, and ssn validations with coding script on the fields.
I will try to keep you posted on my results next week with the server guy.
Rita
7.6.10 Oracle 10g Windows XP
February 10, 2011, 04:24 PM
Francis Mariani
Ouch! I feel your pain.
Even if form validation is not included in HTML Composer, the darn thing shouldn't make it hard for us to do it ourselves.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
April 13, 2011, 08:33 AM
MAdams1
Amen Francis! And thank you for your post....it worked perfect for me.
Michelle
WebFOCUS Server 8.1.05 Windows 2008 Server WebFOCUS AppStudio 8.1.05 Windows 7 Professional IE 11 and Chrome Version 43.0.2357.124 m. Mostly HTML, PDF, Excel, and AHTML
April 13, 2011, 09:54 AM
Francis Mariani
Michelle,
I'm happy you worked it out. There's at least one thing to worry about: what will happen to the code when the HTML page is opened in a newer version of Dev Studio Layout Composer, so, keep your eyes and ears open when you upgrade!
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
December 10, 2011, 05:10 PM
njsden
Thanks all for the hints and Francis for leading me here!This message has been edited. Last edited by: njsden,