in reply to Re: Perl - calling javascript funciton
in thread Perl - calling javascript funciton
Perl File snippet: <SCRIPT LANGUAGE="JavaScript" SRC="/js_validation/js.js"></SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +"> </head> <body> <form onsubmit="return formValidator()"> <table> <tr><td> Test Field: <input type="text" value="--" size="2" maxlength="2" id="p +lace"><br></td> </tr> <input type='submit' value='Check Form'><br> Javascript: /* SOURCE FILE: form_validation.js */ function formValidator(){ var place = document.getElementById("place"); if(isNumeric(place, "Please enter a valid zip code")){ return true; } return false; } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } Unfortunately, because I'm a newbie I don't really understand how to u +sefully incorporate the various modules that are out there. I instal +led the JavaScript::DataFormValidator module this morning, but am not + sure how to incorporate it yet. The only modules I am utilizng in m +y program currently are DBI and CGI. I don't really know the details + of what they do. I just know that the tutorials I've been taking to +ld me to use them :) The idea of putting my javascript into a perl string is intriguing. H +owever, it seems that my code could get real messy real quick. Is it + common in Perl to call functions/variables/etc from an external Perl + file (like you can in JS "..SRC="/js_validation/js.js"></SCRIPT>" )? If so, maybe storing my javascript in a variable within an external fi +le would be a good way to do this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl - calling javascript funciton
by afoken (Chancellor) on Mar 11, 2009 at 15:48 UTC | |
by ax1lla (Initiate) on Mar 12, 2009 at 13:38 UTC |