Commit 36d1d81a45fd4b6bf7365fd46e724312ef6e5368

Authored by rob
1 parent e1f66e65

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 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 22 function stopTable() {
19 23 return "</table>\n";
20 24 }
... ... @@ -23,14 +27,15 @@ function tableRow($align, $bgcolor, $html) {
23 27 return "<tr align=\"$align\" bgcolor=\"$bgcolor\">$html</tr>\n";
24 28 }
25 29  
  30 +
26 31 function tableHeading($cssClassName, $colspan, $text) {
27 32 return "<th colspan=\"$colspan\">\n
28 33 <span class=\"$cssClassName\">$text</span>\n
29 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 41 function tableCssData($html, $cssClass) {
... ... @@ -41,6 +46,10 @@ function startTableRowCell() {
41 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 53 function endTableRowCell() {
45 54 return "</td></tr>\n";
46 55 }
... ... @@ -53,4 +62,36 @@ function generateImage($sImageSource) {
53 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 ?>
... ...