Commit b3eb39b1 authored by Boris Kocherov's avatar Boris Kocherov

use html5 attributes for limitation input fields string and number type

parent 9e2b6711
......@@ -940,6 +940,19 @@
if (type === "number") {
input.setAttribute("step", "any");
}
if (json_field.multipleOf && json_field.multipleOf >= 0) {
input.step = json_field.multipleOf;
}
if (json_field.minimum &&
// step work from min value so we can't
// use min if min not multipleOf step
!(json_field.multipleOf &&
(json_field.minimum % json_field.multipleOf) !== 0)) {
input.min = json_field.minimum;
}
if (json_field.maximum) {
input.max = json_field.maximum;
}
} else {
if (default_value === undefined && typeof json_field.default === "string") {
input.value = json_field.default;
......@@ -948,6 +961,13 @@
input.type = "text";
if (json_field.pattern) {
input.pattern = json_field.pattern;
} else if (json_field.minLength) {
// minLength absent in html5 so
// use pattern for this task
input.pattern = ".{" + json_field.minLength + ",}";
}
if (json_field.maxLength) {
input.maxLength = json_field.maxLength;
}
if (json_field.format === 'uri') {
input.type = "url";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment