Focal Point
[CLOSED] Java Script Form Validation in Webfocus
May 01, 2013, 05:38 AM
Trilochan [CLOSED] Java Script Form Validation in Webfocus
I have a Webfocus HTML form with more than 10 filter Textbox.I want to validate all the text box value using Java Script.
I have written below code.
<!-- Generated by Report Layout Painter -->
<HTML>
<HEAD>
<TITLE>HtmlPage</TITLE>
<BASE href=HTTP://localhost:80>
<META content="MSHTML 6.00.2900.6325" name=GENERATOR>
<SCRIPT id=clientEventHandlersJS type=text/javascript>
//Begin function window_onload
function window_onload() {
UpdateData();
// TODO: Add your event handler code here
}
//End function window_onload
function ValidateForm() {
var edit1 = document.getElementById("edit1").value;
alert(edit1);
if (edit1== "") {
alert("Please enter the Textbox value");
return false;
}
else {
return true;
}
}
</SCRIPT>
<SCRIPT for=window eventname="onload">window.onload = function() { window_onload(); }</SCRIPT>
</HEAD>
<BODY style="OVERFLOW: auto">
<IFRAME id=iframe1 style="Z-INDEX: 3; LEFT: 190px; WIDTH: 650px; POSITION: absolute; TOP: 310px; HEIGHT: 260px" tabIndex=3 name=iframe1 autoExecute="False"></IFRAME>
<FORM id=form2 style="Z-INDEX: 4; LEFT: 210px; WIDTH: 617px; POSITION: absolute; TOP: 50px; HEIGHT: 214px" tabIndex=4 name=form2 onsubmit="OnExecute(this);return false;" method=post autoExecute="True" default_slider_type="4" form_prompt_location="1" form_number_of_visible_rows="4" form_number_of_columns="4" vert_dist_between_controls="10" form_hor_dist_between_controls="10" form_dist_between_desc_and_input="10" requests_list="0">
<INPUT id=form2Submit style="Z-INDEX: 5; LEFT: 141px; BACKGROUND-IMAGE: url(/ibi_html/javaassist/ibi/html/describe/run16.gif); WIDTH: 38px; BACKGROUND-REPEAT: no-repeat; POSITION: absolute; TOP: 174px; HEIGHT: 22px; BACKGROUND-COLOR: lavender" onclick=ValidateForm(); tabIndex=5 type=submit value=" " name=ITEM1>
<INPUT id=form2Reset style="Z-INDEX: 6; LEFT: 271px; BACKGROUND-IMAGE: url(/ibi_html/javaassist/ibi/html/describe/reset.gif); WIDTH: 38px; BACKGROUND-REPEAT: no-repeat; POSITION: absolute; TOP: 164px; HEIGHT: 22px; BACKGROUND-COLOR: lavender" tabIndex=6 type=reset value=" " name=reset1>
<FIELDSET id=form2_formbodyid style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; Z-INDEX: 7; LEFT: 5px; PADDING-BOTTOM: 0px; OVERFLOW: auto; WIDTH: 607px; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; POSITION: absolute; TOP: 5px; HEIGHT: 1px; BORDER-BOTTOM-STYLE: none" tabIndex=7 formbody="1"></FIELDSET>
<INPUT id=edit1 style="Z-INDEX: 8; LEFT: 100px; WIDTH: 260px; POSITION: absolute; TOP: 100px" tabIndex=8 name=edit1></FORM>
<xml id=ibi_requests>
<requests>
<request requestid="0" sourcetype="typeFex" targettype="0" targetname="iframe1" ibif_ex="test.fex" ibic_server="EDASERVE" ibiapp_app="chronos">
<variables/></request></requests>
</xml></BODY></HTML>
Here Validation is works.But the form is submitted.I want to stop submission of form if filter text box is not entered or validated.
In Java script form validation return true means form submission=YES and return false means form submission=NO
Please help me.Thanks in advance.
I am using Dev Studio Version 761.
This message has been edited. Last edited by: <Kathryn Henning>, May 14, 2013 01:21 PM WebFOCUS 7.6.1 Windows, All Outputs
May 01, 2013, 03:36 PM
SeyedG Hi Trilochan,
Change the onclick event from
onclick= ValidateForm();
to
onclick= "return ValidateForm()";
I tried this change, and seems to not submit the form unless a value is entered into the text box. Having the 'Return' before the name prevents the forms submission prematurely. Please see
http://www.webreference.com/pr...t/confirm/index.html for more info.
Seyed
WebFOCUS 8.0.09 App Studio 8009 Linux Kernel-2.6 DBMS: Oracle 11g all output (Excel, HTML, AHTML, PDF)
May 03, 2013, 07:18 AM
Trilochan Hi SeyedG,
Thanks for your reply.
Then also it is not working after using below code
onclick= "return ValidateForm()"; I think form is submitted due to below code
onsubmit="OnExecute(this);return false;" Please help me,how to restrict form submission.
WebFOCUS 7.6.1 Windows, All Outputs
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
May 03, 2013, 11:42 AM
SeyedG quote:
Originally posted by Trilochan:
Hi SeyedG,
Thanks for your reply.
Then also it is not working after using below code
onclick= "return ValidateForm()"; I think form is submitted due to below code
onsubmit="OnExecute(this);return false;" Please help me,how to restrict form submission.
Hi Trilochan,
In your onsubmit event handler, you are calling a function called 'OnExecute' that does not exist. You could add something like:
function OnExecute()
{
alert('Made it to OnExecute');
document.form2.submit();
}
The link Francis suggested contains valuable information that would be helpful to you.
Seyed
WebFOCUS 8.0.09 App Studio 8009 Linux Kernel-2.6 DBMS: Oracle 11g all output (Excel, HTML, AHTML, PDF)
May 16, 2013, 04:26 AM
Trilochan Thanks Francis Mariani for your help.
Its works for me.
WebFOCUS 7.6.1 Windows, All Outputs