N
Nigel
Hello,
I am creating a Perl CGI page with Javascript which I believe has a
problem with the javascript.
Below is my form which has two submit buttons with two different
actions.
I am having an issue with my "Submit FAQ" button. The "Submit FAQ"
button calls the javascript function validate(). This function is
supposed to check to make sure the 'content' field is populated. If
the field is populated it will go to the action page called
"addFAQAction.pl". If the 'content' field in undefined a message will
be displayed to the user stating to populate the 'content' field.
Currently the functionality does not catch when the 'content' field is
blank and just continues to the action page.
Can anyone see what I might be doing wrong which causes my form not to
catch when 'content' is undefined?
Thanks in Advance.
Nigel
#!/usr/bin/perl -w
use strict;
use CGI;
my $content = param('content');
print <<"HTML";
<HTML>
<HEAD>
<SCRIPT language='javascript'>
function checkContent (strng) {
var error = "";
if (strng == ""){
error = "Please enter some content for this FAQ.\n";
}
return error;
}
function validate()
{
var why = "";
why += checkContent(addFAQ.content.value);
if (why != ""){
alert(why);
return false;
}
else{
document.addFAQ.submit();
return true;
}
}
</SCRIPT>
</HEAD>
<BODY>
<form name='addFAQ' id='addFAQ' action='addFAQAction.pl' method='post'>
<table>
<tr>
<td>FAQ Content:<br></td>
HTML
<td><textarea id='content' name='content' cols='70'
rows='20'>$content</textarea></td>
print <<"HTML";
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="update" value="Update Page"
onClick=\"document.addFAQ.action='addFAQ.pl'\">
<input type="submit" name="Submit" value="Submit FAQ"
onSubmit='javascript:validate();'>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
HTML
I am creating a Perl CGI page with Javascript which I believe has a
problem with the javascript.
Below is my form which has two submit buttons with two different
actions.
I am having an issue with my "Submit FAQ" button. The "Submit FAQ"
button calls the javascript function validate(). This function is
supposed to check to make sure the 'content' field is populated. If
the field is populated it will go to the action page called
"addFAQAction.pl". If the 'content' field in undefined a message will
be displayed to the user stating to populate the 'content' field.
Currently the functionality does not catch when the 'content' field is
blank and just continues to the action page.
Can anyone see what I might be doing wrong which causes my form not to
catch when 'content' is undefined?
Thanks in Advance.
Nigel
#!/usr/bin/perl -w
use strict;
use CGI;
my $content = param('content');
print <<"HTML";
<HTML>
<HEAD>
<SCRIPT language='javascript'>
function checkContent (strng) {
var error = "";
if (strng == ""){
error = "Please enter some content for this FAQ.\n";
}
return error;
}
function validate()
{
var why = "";
why += checkContent(addFAQ.content.value);
if (why != ""){
alert(why);
return false;
}
else{
document.addFAQ.submit();
return true;
}
}
</SCRIPT>
</HEAD>
<BODY>
<form name='addFAQ' id='addFAQ' action='addFAQAction.pl' method='post'>
<table>
<tr>
<td>FAQ Content:<br></td>
HTML
<td><textarea id='content' name='content' cols='70'
rows='20'>$content</textarea></td>
print <<"HTML";
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="update" value="Update Page"
onClick=\"document.addFAQ.action='addFAQ.pl'\">
<input type="submit" name="Submit" value="Submit FAQ"
onSubmit='javascript:validate();'>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
HTML