473,573 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

embedding javascript using html into perl script

236 New Member
Hi All,

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
  1. #!c:/perl/bin/perl.exe -w
  2. #!/usr/local/bin/perl
  3.  
  4.  
  5. print "Content-type: text/html\n\n";
  6. print qq%
  7.  
  8. #this portion will be html with javascript alone, except %; at the closing end.
  9. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  10. <html>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  13. <title>L&A Fashion</title>
  14. <meta http-equiv="Page-Enter" content="blendTrans(Duration=1)">
  15. <meta name="GENERATOR" content="Created by BlueVoda">
  16. <script language="JavaScript" type="text/javascript">
  17. <!--
  18. function ValidateForm1(theForm)
  19. {
  20. var strFilter = /^[A-Za-z0-9-]*$/;
  21. var chkVal = theForm.Editbox10.value;
  22. if (!strFilter.test(chkVal))
  23. {
  24.    alert("Username must be minimum 6 characters and maximum 30 characters and it should be digits or alphabets");
  25.    theForm.Editbox10.focus();
  26.    return false;
  27. }
  28. if (theForm.Editbox10.value.length < 6)
  29. {
  30.    alert("Username must be minimum 6 characters and maximum 30 characters and it should be digits or alphabets");
  31.    theForm.Editbox10.focus();
  32.    return false;
  33. }
  34. if (theForm.Editbox10.value.length > 30)
  35. {
  36.    alert("Username must be minimum 6 characters and maximum 30 characters and it should be digits or alphabets");
  37.    theForm.Editbox10.focus();
  38.    return false;
  39. }
  40. return true;
  41. }
  42. //-->
  43. </script>
  44. <style type="text/css">
  45. a.style1:link {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
  46. a.style1:visited {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
  47. a.style1:active {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
  48. a.style1:hover {color: #FF80C0;font-weight: bold;font-style: italic;text-decoration: none;}
  49. </style>
  50. <style type="text/css">
  51. img { behavior: url("pngfix.htc"); }
  52. </style>
  53. </head>
  54. <body bgcolor="#FFFFFF" text="#000000">
  55. <div id="bv_Image1" style="overflow:hidden;position:absolute;left:0px;top:0px;z-index:5" align="left">
  56. <img src="bv01016.jpg" id="Image1" alt="" align="top" border="0" style="width:562px;height:915px;"></div>
  57. <div id="bv_Image10" style="overflow:hidden;position:absolute;left:1039px;top:761px;z-index:6" align="left">
  58. <img src="AL__44_.JPG" id="Image10" alt="" align="top" border="0" style="width:112px;height:96px;"></div>
  59. <div id="bv_Text12" style="position:absolute;left:308px;top:144px;width:100px;height:16px;z-index:7" align="center">
  60. &nbsp;</div>
  61. <div id="bv_Image12" style="overflow:hidden;position:absolute;left:562px;top:0px;z-index:8" align="left">
  62. <img src="bv01017.jpg" id="Image12" alt="" align="top" border="0" style="width:644px;height:915px;"></div>
  63. <div id="bv_Text9" style="position:absolute;left:827px;top:493px;width:122px;height:19px;z-index:9" align="center">
  64. &nbsp;</div>
  65. <div id="bv_Shape2" style="position:absolute;left:196px;top:136px;width:555px;height:553px;z-index:10" align="center">
  66. <img src="bv01042.png" id="Shape2" align="top" alt="" title="" border="0" width="555" height="553"></div>
  67. <div id="bv_Shape3" style="position:absolute;left:378px;top:5px;width:201px;height:125px;z-index:11" align="center">
  68. <img src="bv01050.png" id="Shape3" align="top" alt="" title="" border="0" width="201" height="125"></div>
  69. <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">
  70. <div id="bv_Form1" style="position:absolute;left:201px;top:136px;width:541px;height:463px;z-index:13" align="left">
  71. <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')">
  72. <div id="bv_Text13" style="position:absolute;left:51px;top:138px;width:153px;height:16px;z-index:0" align="right">
  73. <font style="font-size:13px" color="#388E8E" face="Arial"><b>Username * : </b></font></div>
  74. <input type="submit" id="Button1"" name="Button1" value="Sign Up" style="position:absolute;left:225px;top:417px;width:75px;height:24px;z-index:1">
  75. <div id="bv_Text1" style="position:absolute;left:17px;top:66px;width:508px;height:16px;z-index:2" align="left">
  76. <font style="font-size:13px" color="#800080" face="Arial"><b>Please key in below for Registration Sign Up (* denotes Compulsory)</b></font></div>
  77. <div id="bv_Shape1" style="position:absolute;left:211px;top:9px;width:140px;height:53px;z-index:3" align="center">
  78. <img src="bv01052.png" id="Shape1" align="top" alt="" title="" border="0" width="140" height="53"></div>
  79. <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">
  80.  
  81. </form>
  82. </div>
  83. </body>
  84. </html>%;
  85.  
  86.  
Jul 2 '09 #1
3 3897
happyse27
236 New Member
pls advise why onsubmit="retur n ValidateForm1(' this')" did not work in the form validation... The below example worked however...

Expand|Select|Wrap|Line Numbers
  1. #!c:/perl/bin/perl.exe -w
  2. #!/usr/local/bin/perl
  3.  
  4. my $random_number = int( rand( 10)); 
  5.  
  6. print "Content-type: text/html\n\n";
  7. print qq|
  8.  
  9. <html> 
  10. <head> 
  11. <title>A Random Number</title> 
  12.  
  13. <script language="JavaScript" type="text/javascript">
  14. var myNumber = $random_number; 
  15.  
  16. function display() { 
  17. alert( "Your random number is "+ myNumber); 
  18. </script> 
  19.  
  20. <style> 
  21. .display { padding: 50px; text-align: center; background: lightblue; } 
  22. </style> 
  23.  
  24. </head> 
  25.  
  26. <body> 
  27. <div class="display" onMouseOver="display();">HOVER HERE TO SEE THE NUMBER!</div> 
  28. </body> 
  29.  
  30. </html> |;
  31.  
Jul 2 '09 #2
KevinADC
4,059 Recognized Expert Specialist
In your first code you have this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. print qq%
  3.  
  4. #this portion will be html with javascript alone, except %; at the closing end.
  5.  

You need to remove the line that starts with # because that is not a comment that is just text inside of a qq string and the % symbol is breaking your code in that line. I don't know if that will make your javascript code work but it should make your perl code work.
Jul 2 '09 #3
happyse27
236 New Member
oh, the # comment was not part of the code. Only my comments... at wits end. Surveyed many websites... still not able... thanks...
Jul 2 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
8204
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7795
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6424
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3734
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3735
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2223
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1309
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.