Make maxlength in edit fields a soft limit
This commit is contained in:
parent
682e86d236
commit
9872229e11
|
@ -914,7 +914,7 @@ function input($field, $value, $function) {
|
|||
// type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator
|
||||
echo "<input"
|
||||
. ((!$has_function || $function === "") && preg_match('~(?<!o)int~', $field["type"]) ? " type='number'" : "")
|
||||
. " value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "")
|
||||
. " value='" . h($value) . "'" . ($maxlength ? " data-maxlength='$maxlength'" : "")
|
||||
. (preg_match('~char|binary~', $field["type"]) && $maxlength > 20 ? " size='40'" : "")
|
||||
. "$attrs>"
|
||||
;
|
||||
|
|
|
@ -26,6 +26,7 @@ pre, textarea { font: 100%/1.25 monospace; }
|
|||
input[type=image] { vertical-align: middle; }
|
||||
input.default { box-shadow: 1px 1px 1px #777; }
|
||||
input.required { box-shadow: 1px 1px 1px red; }
|
||||
input.maxlength { box-shadow: 1px 1px 1px red; }
|
||||
.block { display: block; }
|
||||
.version { color: #777; font-size: 67%; }
|
||||
.js .hidden, .nojs .jsonly { display: none; }
|
||||
|
|
|
@ -460,16 +460,17 @@ function functionChange(select) {
|
|||
if (selectValue(select)) {
|
||||
if (input.origType === undefined) {
|
||||
input.origType = input.type;
|
||||
input.origMaxLength = input.maxLength;
|
||||
input.origMaxLength = input.getAttribute('data-maxlength');
|
||||
}
|
||||
input.removeAttribute('maxlength');
|
||||
input.removeAttribute('data-maxlength');
|
||||
input.type = 'text';
|
||||
} else if (input.origType) {
|
||||
input.type = input.origType;
|
||||
if (input.origMaxLength >= 0) {
|
||||
input.maxLength = input.origMaxLength;
|
||||
input.setAttribute('data-maxlength', input.origMaxLength);
|
||||
}
|
||||
}
|
||||
oninput({target: input});
|
||||
helpClose();
|
||||
}
|
||||
|
||||
|
@ -793,3 +794,9 @@ function cloneNode(el) {
|
|||
setupSubmitHighlight(el2);
|
||||
return el2;
|
||||
}
|
||||
|
||||
oninput = function (event) {
|
||||
var target = event.target;
|
||||
var maxLength = target.getAttribute('data-maxlength');
|
||||
alterClass(target, 'maxlength', target.value && maxLength != null && target.value.length > maxLength); // maxLength could be 0
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Adminer 4.2.6-dev:
|
||||
Add accessibility labels to Create Table fields
|
||||
Make maxlength in edit fields a soft limit
|
||||
|
||||
Adminer 4.2.5 (released 2016-06-01):
|
||||
Fix remote execution in SQLite query
|
||||
|
|
Loading…
Reference in a new issue