Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with function

Status
Not open for further replies.

sql99

Programmer
Nov 12, 2003
83
US
Hello again,

Can you please help me figure out what is wrong with my code? I have a perl code that was already written and all I need to do is add a maxlength check to ensure that the box1 field does not exceed 100 characters. I added this function in the code:

print TICKET "\n\n";
print TICKET "<HTML>\n";
print TICKET "<HEAD><TITLE>Job $Job_Number</TITLE>\n";
print TICKET <<EOF;
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function maxlength(max){
if (document.section.box1.value.length > max) {
document.section.box1.value = document.section.box1.value.substring
(0,max);
alert ("Please go back and try again");
return false;
}

}
//-->
</script>
EOF
print TICKET "</HEAD>\n";


Then I added name=section to this part:

print TICKET "<FORM name=section ACTION= $url . "/test/site/web.cgi

METHOD=POST>\n";

Then the final thing I did was added onclick to the input submit:

print TICKET "<INPUT TYPE=submit VALUE=\"Send\" onclick=return maxlength(100)><INPUT TYPE=reset>";


When I submit the form, the function isn't being called. Am I doing something wrong here?

Thanks in advance,

sql99
 
I think you should try this one in the JavaScript forum, as it is a very long distance between Perl and JavaScript.

Good luck...
 
sql99,

first off
<!-- hide
should probably be
<!--// hide

onclick=\"return maxlength(100);\"

That's 2 things I'd try
--Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top