MDL-54804 templates: Prevent posting when no option is selected

When no value is set for an option element and a user selects it, a
POST request is made, which is incorrect. Usually that option is a
placeholder value, e.g., "Choose..." - the form expecting the end user
to choose an actual value.
This commit is contained in:
Marcus Fabriczy
2019-01-10 09:04:25 +10:30
parent 38a1b4f203
commit e49603cb5c
+3
View File
@@ -74,6 +74,9 @@
{{#js}}
require(['jquery'], function($) {
$('#{{id}}').change(function() {
if (!$(this).val()) {
return false;
}
$('#{{formid}}').submit();
});
});