I am creating the perl script using html form(with embedded javascript inside).
When using this html form with javascript alone, it works where the form validation will pop up javascript windows to say the field is not keyed into properly. However, when i convert this html(with javascript inside) into perl script, the perl script did not validate when i keyed incorrect data in the form and it straight away executed perl script without using the java script validation.
The code is below.
Thanks and Best Rgds,
Andrew
Perl script - with html(javascript inside also)
Expand|Select|Wrap|Line Numbers
- #!c:/perl/bin/perl.exe -w
- #!/usr/local/bin/perl
- print "Content-type: text/html\n\n";
- print qq%
- #this portion will be html with javascript alone, except %; at the closing end.
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>L&A Fashion</title>
- <meta http-equiv="Page-Enter" content="blendTrans(Duration=1)">
- <meta name="GENERATOR" content="Created by BlueVoda">
- <script language="JavaScript" type="text/javascript">
- <!--
- function ValidateForm1(theForm)
- {
- var strFilter = /^[A-Za-z0-9-]*$/;
- var chkVal = theForm.Editbox10.value;
- if (!strFilter.test(chkVal))
- {
- alert("Username must be minimum 6 characters and maximum 30 characters and it should be digits or alphabets");
- theForm.Editbox10.focus();
- return false;
- }
- if (theForm.Editbox10.value.length < 6)
- {
- alert("Username must be minimum 6 characters and maximum 30 characters and it should be digits or alphabets");
- theForm.Editbox10.focus();
- return false;
- }
- if (theForm.Editbox10.value.length > 30)
- {
- alert("Username must be minimum 6 characters and maximum 30 characters and it should be digits or alphabets");
- theForm.Editbox10.focus();
- return false;
- }
- return true;
- }
- //-->
- </script>
- <style type="text/css">
- a.style1:link {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
- a.style1:visited {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
- a.style1:active {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
- a.style1:hover {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
- </style>
- <style type="text/css">
- img { behavior: url("pngfix.htc"); }
- </style>
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <div id="bv_Image1" style="overflow:hidden;position:absolute;left:0px;top:0px;z-index:5" align="left">
- <img src="bv01016.jpg" id="Image1" alt="" align="top" border="0" style="width:562px;height:915px;"></div>
- <div id="bv_Image10" style="overflow:hidden;position:absolute;left:1039px;top:761px;z-index:6" align="left">
- <img src="AL__44_.JPG" id="Image10" alt="" align="top" border="0" style="width:112px;height:96px;"></div>
- <div id="bv_Text12" style="position:absolute;left:308px;top:144px;width:100px;height:16px;z-index:7" align="center">
- </div>
- <div id="bv_Image12" style="overflow:hidden;position:absolute;left:562px;top:0px;z-index:8" align="left">
- <img src="bv01017.jpg" id="Image12" alt="" align="top" border="0" style="width:644px;height:915px;"></div>
- <div id="bv_Text9" style="position:absolute;left:827px;top:493px;width:122px;height:19px;z-index:9" align="center">
- </div>
- <div id="bv_Shape2" style="position:absolute;left:196px;top:136px;width:555px;height:553px;z-index:10" align="center">
- <img src="bv01042.png" id="Shape2" align="top" alt="" title="" border="0" width="555" height="553"></div>
- <div id="bv_Shape3" style="position:absolute;left:378px;top:5px;width:201px;height:125px;z-index:11" align="center">
- <img src="bv01050.png" id="Shape3" align="top" alt="" title="" border="0" width="201" height="125"></div>
- <img src="bv01051.gif" id="Text2" width="131" height="110" align="top" alt="" border="0" style="position:absolute;left:403px;top:16px;width:131px;height:110px;z-index:12">
- <div id="bv_Form1" style="position:absolute;left:201px;top:136px;width:541px;height:463px;z-index:13" align="left">
- <form name="Form1" method="POST" action="http://127.0.0.1/cgi-bin/acctman2-if.pl" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1('this')">
- <div id="bv_Text13" style="position:absolute;left:51px;top:138px;width:153px;height:16px;z-index:0" align="right">
- <font style="font-size:13px" color="#388E8E" face="Arial"><b>Username * : </b></font></div>
- <input type="submit" id="Button1"" name="Button1" value="Sign Up" style="position:absolute;left:225px;top:417px;width:75px;height:24px;z-index:1">
- <div id="bv_Text1" style="position:absolute;left:17px;top:66px;width:508px;height:16px;z-index:2" align="left">
- <font style="font-size:13px" color="#800080" face="Arial"><b>Please key in below for Registration Sign Up (* denotes Compulsory)</b></font></div>
- <div id="bv_Shape1" style="position:absolute;left:211px;top:9px;width:140px;height:53px;z-index:3" align="center">
- <img src="bv01052.png" id="Shape1" align="top" alt="" title="" border="0" width="140" height="53"></div>
- <input type="text" id="Editbox10" style="position:absolute;left:211px;top:136px;width:160px;font-family:Courier New;font-size:16px;z-index:4" size="16" name="Username" value="" maxlength="30">
- </form>
- </div>
- </body>
- </html>%;