Bug #4012 [NEW]: PEAR HTML/QuickForm Validation JavaScript Problem

From: Date: Thu, 31 Mar 2005 05:40:11 +0000
Subject: Bug #4012 [NEW]: PEAR HTML/QuickForm Validation JavaScript Problem
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-5830@lists.php.net to get a copy of this message
From: tom at gocom dot ca Operating system: Windows 2000 PHP version: 4.3.9 Package: Documentation Bug Type: Bug Bug description: PEAR HTML/QuickForm Validation JavaScript Problem Description: ------------ Client side validation will only discover first broken rule. Additional broken rules do not show up on popup. The JavaScript looks like having all broken rules be shown was intended (I don't understand JavaScript well enough to know why it doesn't). Client side validation could also be improved by having cursor placed in field where validation fails, saving user from having to find field with mouse. Included is JavaScript produced by QuickForm Reproduce code: --------------- <script type="text/javascript"> //<![CDATA[ function validate_page1(frm) { var value = ''; var errFlag = new Array(); _qfMsg = ''; value = frm.elements['first'].value; if (value == '' && !errFlag['name']) { errFlag['name'] = true; _qfMsg = _qfMsg + '\n - First name is required'; } value = frm.elements['last'].value; if (value == '' && !errFlag['name']) { errFlag['name'] = true; _qfMsg = _qfMsg + '\n - Last name is required'; } if (_qfMsg != '') { _qfMsg = 'Invalid information entered.' + _qfMsg; _qfMsg = _qfMsg + '\nPlease correct these fields.'; alert(_qfMsg); return false; } return true; } //]]> </script> Expected result: ---------------- // If both form fields empty, then message box saying: Invalid information entered. - First name is required - Last name is required Please correct these fields. Actual result: -------------- // But instead only get: Invalid information entered. - First name is required Please correct these fields. -- Edit bug report at http://pear.php.net/bugs/bug.php?id=4012&edit=1 --

« previous php.pear.doc (#5830) next »