| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:38:18 2008 ] | [ Tikiwiki 1.9.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 // $Header: /cvsroot/tikiwiki/tiki/function.js_maxlength.php,v 1.4.2.3 2004/08/26 17:38:21 mose Exp $ 3 /** 4 * \brief Smarty {js_maxlength} function handler 5 * 6 * Creates javascript to add 'maxlength' functionality to a <textbox> 7 * Usage: 8 * {js_maxlength textarea=[string] maxlength=[int]} 9 * 10 * TODO would be great if it worked with array arguments 11 * 12 */ 13 14 //this script may only be included - so its better to die if called directly. 15 if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== FALSE) { 16 //smarty is not there - we need setup 17 require_once ('tiki-setup.php'); 18 $smarty->assign('msg',tra("This script cannot be called directly")); 19 $smarty->display("error.tpl"); 20 die; 21 } 22 23 24 function smarty_function_js_maxlength($params, &$smarty) { 25 extract($params); // textarea=string maxlength=num 26 27 echo "\n<script type=\"text/javascript\" language=\"Javascript1.2\">\n"; 28 echo "<!--\n"; 29 // 30 // TODO this is the best I can get a countdown to work but it is still not 31 // good enough. Improve or Remove permanently 32 // function textCounter(f, countf, maxl) { 33 // if ( f.value.length > maxl-1 ) { 34 // f.value = f.value.substring(0, maxl-1); 35 // alert( 'This text can only be ' + maxl + ' characters long.' ); 36 // return false; 37 // } else { 38 // countf.value = maxl - 1 - f.value.length; 39 // } 40 //} 41 echo "function verifyForm(f){\n"; 42 echo " var rtn=true;\n"; 43 echo " if ( f.$textarea.value.length > $maxlength ) {\n"; 44 echo " f.$textarea.style.color='red';\n"; 45 echo " alert('" . tra("The text in RED is") . " ' + (f.$textarea.value.length - $maxlength) + ' " . tra("character(s) too long - please edit it.") . "');\n"; 46 echo " rtn = false;\n"; 47 echo " }\n"; 48 echo " return rtn;\n"; 49 echo "}\n"; 50 echo "//-->\n"; 51 echo "</script>\n"; 52 } 53 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |