JavaScript in CMS
JavaScript can be used in CMS on a eWeb Page Detail or Default pane for a Web Site or Web Section.
Case Study
Required Field Validation
Here is an example of using JavaScript to make a field be required on a Find page using the FindControl. Note that the field names are variable depending on their order.
<TABLE><TBODY><TR><TD><SCRIPT src="../../eweb/include/dropdown_menus.js" type=text/javascript></SCRIPT> <SCRIPT>eval(ElementValue("eWebForm","C_4_1_ButtonFindGo")).onclick=function () { var req=new Array();var okSoFar=true;var element="";var msg="";var empty_fields="";req[0]=ElementValue("eWebForm","C_4_1_ValueTextBox0");req[1]=ElementValue("eWebForm","C_4_1_ValueTextBox1");req[2]=ElementValue("eWebForm","C_4_1_ValueTextBox2");for(var i=0; i < req.length; i++){var e=eval(req[i]+".value");if((e==null)||(e=="")){empty_fields+="\n"+eval(req[i]+".title");continue;}}if (!empty_fields) okSoFar==true;if(empty_fields){msg+="\n\nThe form is not submitted because of the following error(s):\n\n";okSoFar==false;msg+="First Name, Last Name and Organization are required\n";msg+="Please correct and re-submit.\n\n";alert(msg);return false;}if (okSoFar==true){return true;submit();} };</SCRIPT></TD></TR></TBODY></TABLE><BR><BR>
Braces in JavaScript
Please be aware that due to some changes in how netFORUM ) parses inline JavaScript you need to replace the curly brace characters "{" and "}" with square bracket/pipe character combinations [| and |] to get the same results.
Will not work:
<Script type=text/JavaScript>Function { doSomething}</Script>
Change to this so it will work:
<Script type=text/JavaScript>Function [| doSomething|]</Script>