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
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