diff --git a/CHANGES.md b/CHANGES.md
index 67b02d2cb..44176df27 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -18,6 +18,7 @@ Three config settings have been obsoleted:
- show_images_inline
- muc_show_ogp_unfurls
+- Use more specific types for form fields based on XEP-0122
### Breaking Changes
diff --git a/conversejs.doap b/conversejs.doap
index e961899fd..b998701eb 100644
--- a/conversejs.doap
+++ b/conversejs.doap
@@ -87,6 +87,13 @@
advertises caps but no caching
+
+
+
+ partial
+ basic string field sub-type usage
+
+
diff --git a/src/utils/html.js b/src/utils/html.js
index 9b67dff4c..3270cd159 100644
--- a/src/utils/html.js
+++ b/src/utils/html.js
@@ -44,8 +44,26 @@ const XFORM_TYPE_MAP = {
'list-multi': 'dropdown'
};
+const XFORM_VALIDATE_TYPE_MAP = {
+ 'xs:anyURI': 'url',
+ 'xs:byte': 'number',
+ 'xs:date': 'date',
+ 'xs:dateTime': 'datetime',
+ 'xs:int': 'number',
+ 'xs:integer': 'number',
+ 'xs:time': 'time',
+}
+
function getInputType(field) {
- return XFORM_TYPE_MAP[field.getAttribute('type')]
+ const type = XFORM_TYPE_MAP[field.getAttribute('type')]
+ if (type == 'text') {
+ const datatypes = field.getElementsByTagNameNS("http://jabber.org/protocol/xdata-validate", "validate");
+ if (datatypes.length === 1) {
+ const datatype = datatypes[0].getAttribute("datatype");
+ return XFORM_VALIDATE_TYPE_MAP[datatype] || type;
+ }
+ }
+ return type;
}
function slideOutWrapup (el) {