Re: [QF] Changing the default javascript script

From: Date: Tue, 10 Jan 2006 19:00:23 +0000
Subject: Re: [QF] Changing the default javascript script
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22491@lists.php.net to get a copy of this message
On 1/10/06, Mark Steudel <mark@netriver.net> wrote: > Im trying to modify the main validation javascript: > > return > "\n<script type=\"text/javascript\">\n" . > "//<![CDATA[\n" . > "function validate_" . $this->_attributes['id'] . > "(frm, > verbose) {\n" . > " var verbose = (!verbose) ? 1 : 0;\n" . > " var value = '';\n" . > " var errFlag = new Array();\n" . > " var _qfGroups = {};\n" . > " _qfMsg = '';\n\n" . > join("\n", $test) . > "\n if (_qfMsg != '' && verbose) {\n" . > " _qfMsg = '" . strtr($this->_jsPrefix, $js_escape) .. > "' > + _qfMsg;\n" . > " _qfMsg = _qfMsg + '\\n" . strtr($this->_jsPostfix, > $js_escape) . "';\n" . > " alert(_qfMsg);\n" . > " return false;\n" . > " }\n" . > " return true;\n" . > "}\n" . > "//]]>\n" . > "</script>"; > } > > Basically all it's doing is supressing the alerts if I want. I want to be > able to run another script if the whole form passes validation: > > function new_script() > { > var verbose = 0; > if ( validate_formname( formid, verbose ) ) > { > do something here; > } > } > > I copied the whole getValidationScript() script out of the QuickForm class > and thought perhaps I could extend the QuickForm class and some how tell my > form to use this function instead of it's default function. So now I'm not > really sure where to go from here. > Make a class which extends HTML_QuickForm, then use it to create your form. It's that simple. class MyForm extends HTML_QuickForm { function getValidationScript() { //... } } $form = new MyForm(); -- Justin Patrin

« previous php.pear.general (#22491) next »