Permalink
Browse files

Merge branch 'wip-mdl-27728-m20' of git://github.com/rajeshtaneja/moo…

…dle into MOODLE_20_STABLE
  • Loading branch information...
2 parents 46894c5 + 6a008b4 commit 76a07a1da53c7b00bb91188b66f20715acffc050 @stronk7 stronk7 committed Aug 16, 2011
Showing with 19 additions and 4 deletions.
  1. +19 −4 lib/formslib.php
View
@@ -1716,6 +1716,12 @@ function getValidationScript()
function qf_errorHandler(element, _qfMsg) {
div = element.parentNode;
+
+ if ((div == undefined) || (element.name == undefined)) {
+ //no checking can be done for undefined elements so let server handle it.
+ return true;
+ }
+
if (_qfMsg != \'\') {
var errorSpan = document.getElementById(\'id_error_\'+element.name);
if (!errorSpan) {
@@ -1765,16 +1771,25 @@ function qf_errorHandler(element, _qfMsg) {
$elementName);
$js .= '
function validate_' . $this->_formName . '_' . $escapedElementName . '(element) {
+ if (undefined == element) {
+ //required element was not found, then let form be submitted without client side validation
+ return true;
+ }
var value = \'\';
var errFlag = new Array();
var _qfGroups = {};
var _qfMsg = \'\';
var frm = element.parentNode;
- while (frm && frm.nodeName.toUpperCase() != "FORM") {
- frm = frm.parentNode;
+ if ((undefined != element.name) && (frm != undefined)) {
+ while (frm && frm.nodeName.toUpperCase() != "FORM") {
+ frm = frm.parentNode;
+ }
+ ' . join("\n", $jsArr) . '
+ return qf_errorHandler(element, _qfMsg);
+ } else {
+ //element name should be defined else error msg will not be displayed.
+ return true;
}
-' . join("\n", $jsArr) . '
- return qf_errorHandler(element, _qfMsg);
}
';
$validateJS .= '

0 comments on commit 76a07a1

Please sign in to comment.