Home » HTML » HTML_QuickForm » Bug #4012
PEAR HTML/QuickForm Validation JavaScript Problem
Details
| Submitted | 2005-03-31 05:40 UTC |
|---|---|
| From | tom at gocom dot ca |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 4.3.9 |
| OS | Windows 2000 |
| Roadmaps | (Not assigned) |
Comments
[2005-03-31 05:40 UTC] tom at gocom dot ca
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.