diff options
-rw-r--r-- | js/messages.php | 8 | ||||
-rw-r--r-- | js/tbl_change.js | 69 | ||||
-rw-r--r-- | libraries/js_escape.lib.php | 4 |
3 files changed, 65 insertions, 16 deletions
diff --git a/js/messages.php b/js/messages.php index 8b926bfe53..3c02df1ae7 100644 --- a/js/messages.php +++ b/js/messages.php @@ -715,8 +715,8 @@ $.extend($.timepicker._defaults, $.timepicker.regional['']); <?php /* Form validation */ -echo "function extendingValidatorMessages() {"; -echo "$.extend($.validator.messages, {"; +echo "function extendingValidatorMessages() {\n"; +echo "$.extend($.validator.messages, {\n"; /* Default validation functions */ PMA_printJsValueForFormValidation('required', __('This field is required')); PMA_printJsValueForFormValidation('remote', __('Please fix this field')); @@ -738,6 +738,6 @@ PMA_printJsValueForFormValidation('min', __('Please enter a value greater than o PMA_printJsValueForFormValidation('validationFunctionForDateTime', __('Please enter a valid date or time'), true); PMA_printJsValueForFormValidation('validationFunctionForHex', __('Please enter a valid HEX input'), true); PMA_printJsValueForFormValidation('validationFunctionForFuns', __('Error'), true, false); -echo "});"; -echo "}"; +echo "\n});"; +echo "\n} /* if ($.validator) */"; ?> diff --git a/js/tbl_change.js b/js/tbl_change.js index 8b483dc558..eb09cd3eb5 100644 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -182,7 +182,12 @@ function verificationsAfterFieldChange(urlField, multi_edit, theType) || target.value === 'AES_ENCRYPT' || target.value === 'MD5') { $('#' + target.id).rules("add", { - validationFunctionForFuns : $this_input + validationFunctionForFuns: { + param: $this_input, + depends: function() { + return checkForCheckbox(multi_edit); + } + } }); } @@ -207,36 +212,80 @@ function verificationsAfterFieldChange(urlField, multi_edit, theType) // validate for date time if (theType == "datetime" || theType == "time" || theType == "date" || theType == "timestamp") { $this_input.rules("add", { - validationFunctionForDateTime : theType + validationFunctionForDateTime: { + param: theType, + depends: function() { + return checkForCheckbox(multi_edit); + } + } }); } //validation for integer type if ($this_input.data('type') === 'INT') { - var min = $this_input.attr('min'); - var max = $this_input.attr('max'); + var mini = parseInt($this_input.attr('min')); + var maxi = parseInt($this_input.attr('max')); $this_input.rules("add", { - maxlength : max, - minlength : min + number: { + param : true, + depends: function() { + return checkForCheckbox(multi_edit); + } + }, + min: { + param: mini, + depends: function() { + if (isNaN($this_input.val())) return false; + else return checkForCheckbox(multi_edit); + } + }, + max: { + param: maxi, + depends: function() { + if (isNaN($this_input.val())) return false; + else return checkForCheckbox(multi_edit); + } + } }); //validation for CHAR types } else if ($this_input.data('type') === 'CHAR') { var maxlen = $this_input.data('maxlength'); if (maxlen <=4) { - maxlen=charExceptionHandling + maxlen=charExceptionHandling; } $this_input.rules("add", { - maxlength : maxlen + maxlength: { + param: maxlen, + depends: function() { + return checkForCheckbox(multi_edit); + } + } }); // validate binary & blob types } else if ($this_input.data('type') === 'HEX') { $this_input.rules("add", { - validationFunctionForHex : true + validationFunctionForHex: { + param: true, + depends: function() { + return checkForCheckbox(multi_edit); + } + } }); } if (removeOnclick === 1) $this_input.removeAttr('onchange'); } } - /* End of fields validation*/ +/* End of fields validation*/ + +/** + * To check whether insert section is ignored or not + */ +function checkForCheckbox(multi_edit) +{ + if($("#insert_ignore_"+multi_edit).length) { + return $("#insert_ignore_"+multi_edit).is(":unchecked"); + } + return true; +} /** * Applies the selected function to all rows to be inserted. diff --git a/libraries/js_escape.lib.php b/libraries/js_escape.lib.php index 550d3dc9fc..3af1db88e4 100644 --- a/libraries/js_escape.lib.php +++ b/libraries/js_escape.lib.php @@ -145,7 +145,7 @@ function PMA_printJsValue($key, $value) */ function PMA_getJsValueForFormValidation($key, $value, $addOn, $comma) { - $result = $key . ' : '; + $result = $key . ': '; if ($addOn) { $result .= '$.validator.format('; } @@ -154,7 +154,7 @@ function PMA_getJsValueForFormValidation($key, $value, $addOn, $comma) $result .= ')'; } if ($comma) { - $result .= ','; + $result .= ', '; } return $result; } |