Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions share/templates/dist/search.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
self.poll(res.dists, input.value, 0);
});
});

input.addEventListener('keyup', function () {
input.value = input.value.replace(new RegExp("([^a-zA-Z0-9\-]+)", "g"), "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do this without JavaScript if you'd like by using the <input pattern="..." /> HTML attribute (MDN docs). If the input doesn't pass validation, the submit event shouldn't(?) happen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a preference, I prefer validating the input and preventing the characters this way.

});
},
switchSearchMode: function (type) {
let self = this;
Expand Down