Skip to content

Commit

Permalink
Merge branch 'TomeCirun-7915-fix-for-HTML5-validation'
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Nov 24, 2023
2 parents 8ddc2e8 + ff6ced4 commit 1fbfe62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/7925.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix HTML5 validation failing on resource uploads
11 changes: 11 additions & 0 deletions ckan/public/base/javascript/modules/resource-upload-field.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
this.ckan.module('resource-upload-field', function (jQuery) {
var _nameIsDirty = !! $('input[name="name"]').val();
var urlField = $('#field-resource-url');
return {
initialize: function() {
$('input[name="name"]').on('change', function() {
_nameIsDirty = true;
});

// Change input type to text if Upload is selected
if ($('#resource-url-upload').prop('checked')) {
urlField.attr('type', 'text');
}

// revert to URL for Link option
$('#resource-link-button').on('click', function() {
urlField.attr('type', 'url');
})

$('#field-resource-upload').on('change', function() {
if (_nameIsDirty) {
return;
Expand Down

0 comments on commit 1fbfe62

Please sign in to comment.