RE: [PHP] Form validation of dynamically generated forms?
| From: | Chad Day | Date: | Mon, 28 Aug 2000 20:30:16 +0000 |
| Subject: | RE: [PHP] Form validation of dynamically generated forms? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13995@lists.php.net to get a copy of this message | ||
No answers yet.. I've been searching around some archives, and found this:
>I was not clear in my earlier email. The javascript function is not
>written inside PHP tags. It is actually an included file. I
>attempted this and it won't work. Thanks though.
>MN
which is not directly related to what I'm doing, but is still javascript
written in PHP.
I've had my javascript code looked over, and either people have told me 1)
it should work or 2) not replied. Only works in IE, not NS.
Is this a PHP problem? I at least want to get it narrowed down to that so I
can explore other solutions.
Chad
-----Original Message-----
From: Chad Day [mailto:cday@beachassociates.com]
Sent: Monday, August 28, 2000 12:19 PM
To: 'php-general@lists.php.net'
Subject: [PHP] Form validation of dynamically generated forms?
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net