K
Kuna
Hi All,
I am trying to use Java script to validate the form fields. The code is
written in Perl and it is having a .pm extension for this form also
there is a index.pl file which is containing the "Save" button and the
form is posting the data to index.pl file and then it again comes to
the methods written in the .pm file which is validating the form using
server side code and submit that. But I am not able to get that where
to do the Java script validation that will validate the form in the
client side. Here I am having some codes that will give some idea about
my form.
<code>
print "<body>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='22%' height='18'><img src='./images/logo_mmna.jpg'
width='227' height='57'></td>
<td width=''3%'> </td>
<td width='49%'>
<div align='center' class='v10b'><span class='style3'>"
. $self->getText("NOTICE OF DESIGN PROCESS CHANGE") .
"</span><br>
</div></td>
<td width='26%' valign='top'><table width='100%' border='0'
cellspacing='0' cellpadding='0'>
<!--DWLayoutTable-->
<tr>
<td height='18' colspan='3'> </td>
</tr>
<tr>
<td width='20%' height='18' class='v10b'><label>"
. $self->getText("Date:") . " </label></td>
<td width='17%'>";
print hidden(
-name => '.formId',
-value => '4MChange',
-tabindex => '-1',
-override => 1
);
print textfield(
-name => 'txt-date',
-value => $self->retSysTime,
-id => 'txt-date',
-class => 'formelements',
-size => '10',
-title => 'Today\'s date',
-tabindex => $tabindex
).'*';
foreach my $thisLabel (@singleEntryFields) {
$result->{$thisLabel} = textfield(
-name => sprintf( "txt-%s", $thisLabel ),
-value => $data{$thisLabel},
-id => sprintf( "txt-%s", $thisLabel ),
-class => ( $errLabel eq $thisLabel )
? 'formmsg'
: 'formelements',
-size => $sizeHash{$thisLabel},
-title => $titleHash{$thisLabel},
-force => 1
);
}
print "<td>
<td height=\"10\" colspan=\"3\"><img src=\"/images/spacer.gif\"
width=\"5\" height=\"8\"></td>
</tr>
<tr>
<td height=\"18\"></td>
<td colspan=\"2\"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height=\"18\" colspan=\"4\"> </td>
</tr>
<tr valign=\"top\">
<td height=\"14\" colspan=\"4\"><div align=\"left\"
class=\"v10b\"><label>"
. $self->getText('* indicates a field is required')
. "</label></div>";
print p();
print
"<table width=\"100%\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\" bgcolor=\"#E9E9E9\">
<tr>
<td width=\"35%\" valign=\"top\"><table width=\"100%\"
border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td width=\"22%\"><div align=\"right\"
class=\"v10b\"><label>"
. $self->getText("Supplier Name") . "</label>: </div></td>
<td width=\"20%\">";
$tabindex++;
print $result->{'sname'}.'*';
print "</td>
</tr>
<tr>
<td colspan='2'><img src='/images/spacer.gif' width='5'
height='8'></td>
</tr>
<tr>
<td><div align='right' class='v10b'><label>"
. $self->getText("Supplier Code:") . "</label> </div></td>
<td align ='left'>";
$tabindex++;
print $result->{'scode'}.'*';
print "</td>
</tr>
</table></td>
<td width='35%' valign=\"top\">
<table width='100%' border='0' align='left' cellpadding='0'
cellspacing='0'>
<tr>
<td width='28%'><div align='right' class='v10b'><label>"
. $self->getText("Supplier Contact:") . " </label>
</div></td>
<td width='14%'>";
$tabindex++;
print $result->{'scontact'}.'*';
print "</td>
</tr>
<tr>
<td colspan='2'><img src='/images/spacer.gif' width='5'
height='8'></td>
</tr>
<tr>
<td><div align='right' class='v10b'><label>"
. $self->getText("Supplier Fax:") . " </label></div></td>
<td align='left'>";
$tabindex++;
print $result->{'sfax'}.'*';
print "</td>
</tr>
</table></td>
<td width='30%' valign=\"top\">
</code>
This the form in the .pm file and in the index.pl is having the button
as below:
<code>
if ( param() ) {
$act = $cgi->param('act') || "preprocess";
$button = $cgi->param('button') || 'Save';
$no = ( defined $cgi->param('.no') ) ? ( $cgi->param('.no') ) :
$defaultNo;
$tloc = $cgi->param('.tloc');
$tsvData = $cgi->param('data');
my $error;
$formId =
( defined $cgi->param('.formId') ) ? $cgi->param('.formId') :
$formId;
my $ev = sprintf
'use ACI::WebForms::Form%s; $thisform = new
ACI::WebForms::Form%s();',
$formId, $formId;
if ( !eval $ev ) {
die $@;
}
<./code>
So what I am not able to get that since I am new to Perl, so I am not
getting any <form> tag where I can use the Java script call. Also I am
not getting any solution where to add the Java script that will take
the form input data and validate it.
Sorry if I had missed any information....Please look into this I need a
urgent help.......
Thanks and Regards,
Kuna
I am trying to use Java script to validate the form fields. The code is
written in Perl and it is having a .pm extension for this form also
there is a index.pl file which is containing the "Save" button and the
form is posting the data to index.pl file and then it again comes to
the methods written in the .pm file which is validating the form using
server side code and submit that. But I am not able to get that where
to do the Java script validation that will validate the form in the
client side. Here I am having some codes that will give some idea about
my form.
<code>
print "<body>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='22%' height='18'><img src='./images/logo_mmna.jpg'
width='227' height='57'></td>
<td width=''3%'> </td>
<td width='49%'>
<div align='center' class='v10b'><span class='style3'>"
. $self->getText("NOTICE OF DESIGN PROCESS CHANGE") .
"</span><br>
</div></td>
<td width='26%' valign='top'><table width='100%' border='0'
cellspacing='0' cellpadding='0'>
<!--DWLayoutTable-->
<tr>
<td height='18' colspan='3'> </td>
</tr>
<tr>
<td width='20%' height='18' class='v10b'><label>"
. $self->getText("Date:") . " </label></td>
<td width='17%'>";
print hidden(
-name => '.formId',
-value => '4MChange',
-tabindex => '-1',
-override => 1
);
print textfield(
-name => 'txt-date',
-value => $self->retSysTime,
-id => 'txt-date',
-class => 'formelements',
-size => '10',
-title => 'Today\'s date',
-tabindex => $tabindex
).'*';
foreach my $thisLabel (@singleEntryFields) {
$result->{$thisLabel} = textfield(
-name => sprintf( "txt-%s", $thisLabel ),
-value => $data{$thisLabel},
-id => sprintf( "txt-%s", $thisLabel ),
-class => ( $errLabel eq $thisLabel )
? 'formmsg'
: 'formelements',
-size => $sizeHash{$thisLabel},
-title => $titleHash{$thisLabel},
-force => 1
);
}
print "<td>
<td height=\"10\" colspan=\"3\"><img src=\"/images/spacer.gif\"
width=\"5\" height=\"8\"></td>
</tr>
<tr>
<td height=\"18\"></td>
<td colspan=\"2\"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height=\"18\" colspan=\"4\"> </td>
</tr>
<tr valign=\"top\">
<td height=\"14\" colspan=\"4\"><div align=\"left\"
class=\"v10b\"><label>"
. $self->getText('* indicates a field is required')
. "</label></div>";
print p();
"<table width=\"100%\" border=\"0\" cellpadding=\"0\"
cellspacing=\"0\" bgcolor=\"#E9E9E9\">
<tr>
<td width=\"35%\" valign=\"top\"><table width=\"100%\"
border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td width=\"22%\"><div align=\"right\"
class=\"v10b\"><label>"
. $self->getText("Supplier Name") . "</label>: </div></td>
<td width=\"20%\">";
$tabindex++;
print $result->{'sname'}.'*';
print "</td>
</tr>
<tr>
<td colspan='2'><img src='/images/spacer.gif' width='5'
height='8'></td>
</tr>
<tr>
<td><div align='right' class='v10b'><label>"
. $self->getText("Supplier Code:") . "</label> </div></td>
<td align ='left'>";
$tabindex++;
print $result->{'scode'}.'*';
print "</td>
</tr>
</table></td>
<td width='35%' valign=\"top\">
<table width='100%' border='0' align='left' cellpadding='0'
cellspacing='0'>
<tr>
<td width='28%'><div align='right' class='v10b'><label>"
. $self->getText("Supplier Contact:") . " </label>
</div></td>
<td width='14%'>";
$tabindex++;
print $result->{'scontact'}.'*';
print "</td>
</tr>
<tr>
<td colspan='2'><img src='/images/spacer.gif' width='5'
height='8'></td>
</tr>
<tr>
<td><div align='right' class='v10b'><label>"
. $self->getText("Supplier Fax:") . " </label></div></td>
<td align='left'>";
$tabindex++;
print $result->{'sfax'}.'*';
print "</td>
</tr>
</table></td>
<td width='30%' valign=\"top\">
</code>
This the form in the .pm file and in the index.pl is having the button
as below:
<code>
if ( param() ) {
$act = $cgi->param('act') || "preprocess";
$button = $cgi->param('button') || 'Save';
$no = ( defined $cgi->param('.no') ) ? ( $cgi->param('.no') ) :
$defaultNo;
$tloc = $cgi->param('.tloc');
$tsvData = $cgi->param('data');
my $error;
$formId =
( defined $cgi->param('.formId') ) ? $cgi->param('.formId') :
$formId;
my $ev = sprintf
'use ACI::WebForms::Form%s; $thisform = new
ACI::WebForms::Form%s();',
$formId, $formId;
if ( !eval $ev ) {
die $@;
}
<./code>
So what I am not able to get that since I am new to Perl, so I am not
getting any <form> tag where I can use the Java script call. Also I am
not getting any solution where to add the Java script that will take
the form input data and validate it.
Sorry if I had missed any information....Please look into this I need a
urgent help.......
Thanks and Regards,
Kuna