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&#40;ElementValue&#40;"eWebForm","C_4_1_ButtonFindGo"&#41;&#41;.onclick=function &#40;&#41; { var req=new Array&#40;&#41;;var okSoFar=true;var element="";var msg="";var empty_fields="";req&#91;0&#93;=ElementValue&#40;"eWebForm","C_4_1_ValueTextBox0"&#41;;req&#91;1&#93;=ElementValue&#40;"eWebForm","C_4_1_ValueTextBox1"&#41;;req&#91;2&#93;=ElementValue&#40;"eWebForm","C_4_1_ValueTextBox2"&#41;;for&#40;var i=0; i < req.length; i++&#41;{var e=eval&#40;req&#91;i&#93;+".value"&#41;;if&#40;&#40;e==null&#41;||&#40;e==""&#41;&#41;{empty_fields+="\n"+eval&#40;req&#91;i&#93;+".title"&#41;;continue;}}if &#40;!empty_fields&#41; okSoFar==true;if&#40;empty_fields&#41;{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&#40;msg&#41;;return false;}if &#40;okSoFar==true&#41;{return true;submit&#40;&#41;;} };</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>