Form validation of dynamically generated forms?

From: Date: Mon, 28 Aug 2000 16:19:00 +0000
Subject: Form validation of dynamically generated forms?
Groups: php.general 
Request: Send a blank email to php-general+get-13962@lists.php.net to get a copy of this message
Having some trouble with this one.. trying to get form validation working on dynamically generated PHP forms.. if there's a code snippet out there that would help with what I have below, I would appreciate a link.. or if anyone here knows JS (I realize this is not a JS list), please drop me a line privately if you see the bug below. I tried writing some Javascript in PHP, and it works great in IE.. but in NS it dies. Returns a form has no properties error, and does not check for validation. echo "\n\n<script Language=\"JavaScript\">\n"; echo "<!--\n"; echo "function Form_Validator() {\n"; for ($x = 0; $x <= $MAX; $x++) { if((isset($ORDER[$x])) && ($ORDER[$x] == "checked")) { // loop through the array to get the values of the boxes we need to print out/validate echo "\t\tif (document.myForm.QUANTITY$x.value == '') {\n"; echo "\t\t\talert(\"You must enter a value for the Quantity field.\")\n"; echo "\t\t\tdocument.myForm.QUANTITY$x.focus();\n"; echo "\t\t\treturn (false);\n"; echo "\t\t}\n"; echo "\t\tif (document.myForm.DOCKDATE$x.value == '') {\n"; echo "\t\t\talert(\"You must enter a value for the Dock Date field.\")\n"; echo "\t\t\tdocument.myForm.DOCKDATE$x.focus();\n"; echo "\t\t\treturn (false);\n"; echo "\t\t}\n"; } } echo "\treturn (true);\n"; echo "}\n"; echo "//-->\n"; echo "</script>\n"; I've looked around at form validation scripts for PHP, but I haven't seen anything that would really work for dynamically generated stuff without extensive modifying, which is probably beyond my skill level at this point. Are there any scripts out there that do this, or does anyone know what is wrong with my above code? The thing that annoys me is I use PHP generated javascript elsewhere in the site for form validation, and it works fine.. but those name boxes are static, not dynamic.. I don't know if that's the problem or not. Chad Day Beach Associates When I speak german... I think german in my head... but like...Do skript kiddies see a w40l3 8uncha 1's and 0's and 3's and 4's and 7's in their h34d'5 w43n t43y R +a1k1n6 ? -- SirStanley

« previous php.general (#13962) next »