Commit dca97ef898dca40218403765be51eb4cee087bad

Authored by rob
1 parent e16ee6f4

Added jscript stuff for text/number validation


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@551 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 43 additions and 2 deletions
presentation/Html.inc
@@ -15,6 +15,10 @@ function startTable($border, $width) { @@ -15,6 +15,10 @@ function startTable($border, $width) {
15 return "<table border=\"$border\" width=\"$width\">\n"; 15 return "<table border=\"$border\" width=\"$width\">\n";
16 } 16 }
17 17
  18 +function tableCaption($sCaption) {
  19 + return "<caption><b>$sCaption</b></caption>\n";
  20 +}
  21 +
18 function stopTable() { 22 function stopTable() {
19 return "</table>\n"; 23 return "</table>\n";
20 } 24 }
@@ -23,14 +27,15 @@ function tableRow($align, $bgcolor, $html) { @@ -23,14 +27,15 @@ function tableRow($align, $bgcolor, $html) {
23 return "<tr align=\"$align\" bgcolor=\"$bgcolor\">$html</tr>\n"; 27 return "<tr align=\"$align\" bgcolor=\"$bgcolor\">$html</tr>\n";
24 } 28 }
25 29
  30 +
26 function tableHeading($cssClassName, $colspan, $text) { 31 function tableHeading($cssClassName, $colspan, $text) {
27 return "<th colspan=\"$colspan\">\n 32 return "<th colspan=\"$colspan\">\n
28 <span class=\"$cssClassName\">$text</span>\n 33 <span class=\"$cssClassName\">$text</span>\n
29 </th>\n"; 34 </th>\n";
30 } 35 }
31 36
32 -function tableData($html) {  
33 - return "<td>$html</td>\n"; 37 +function tableData($html, $iColspan = 1) {
  38 + return "<td colspan = $iColspan>$html</td>\n";
34 } 39 }
35 40
36 function tableCssData($html, $cssClass) { 41 function tableCssData($html, $cssClass) {
@@ -41,6 +46,10 @@ function startTableRowCell() { @@ -41,6 +46,10 @@ function startTableRowCell() {
41 return "<tr><td>\n"; 46 return "<tr><td>\n";
42 } 47 }
43 48
  49 +function textInput($sId, $sValue) {
  50 + return "<input type=text id=\"$sId\" value=\"$sValue\" />\n";
  51 +}
  52 +
44 function endTableRowCell() { 53 function endTableRowCell() {
45 return "</td></tr>\n"; 54 return "</td></tr>\n";
46 } 55 }
@@ -53,4 +62,36 @@ function generateImage($sImageSource) { @@ -53,4 +62,36 @@ function generateImage($sImageSource) {
53 return "<img border=\"0\" src=\"$sImageSource\">"; 62 return "<img border=\"0\" src=\"$sImageSource\">";
54 } 63 }
55 64
  65 +function getNumberStringValidationJavaScript() {
  66 + return "<script language=\"JavaScript\">\n".
  67 + "<!--\n" .
  68 + "function validateString(field, msg, min, max) {\n" .
  69 + "\tif (!min) { min = 1 }\n" .
  70 + "\tif (!max) { max = 65535 }\n\n" .
  71 +
  72 + "\tif (!field.value || field.value.length < min || field.value.max > max) {\n" .
  73 + "\t\talert(msg);\n" .
  74 + "\t\tfield.focus();\n" .
  75 + "\t\tfield.select();\n" .
  76 + "\t\treturn false;\n" .
  77 + "\t}\n" .
  78 + "\treturn true;\n" .
  79 + "}\n\n" .
  80 +
  81 + "function validateNumber(field, msg, min, max) {\n" .
  82 + "\tif (!min) { min = 0 }\n" .
  83 + "\tif (!max) { max = 255 }\n" .
  84 +
  85 + "\tif ( (parseInt(field.value) != field.value) || field.value.length < min || field.value.length > max) {\n" .
  86 + "\t\talert(msg);\n" .
  87 + "\t\tfield.focus();\n" .
  88 + "\t\tfield.select();\n" .
  89 + "\t\treturn false;\n" .
  90 + "\t}\n" .
  91 + "\treturn true;\n" .
  92 + "}\n" .
  93 + "//-->\n" .
  94 + "</script>\n";
  95 +}
  96 +
56 ?> 97 ?>