Merge pull request #1930 from basecamp/prevent-blank-board-names
Prevent board names with only spaces and show validation message
This commit is contained in:
@@ -21,8 +21,13 @@ export default class extends Controller {
|
||||
|
||||
if (input) {
|
||||
const value = (input.value || "").trim()
|
||||
if (value.length === 0) {
|
||||
const isEmpty = value.length === 0
|
||||
|
||||
if (isEmpty) {
|
||||
event.preventDefault()
|
||||
input.setCustomValidity(input.dataset.validationMessage || "Please fill out this field")
|
||||
input.reportValidity()
|
||||
input.addEventListener("input", () => input.setCustomValidity(""), { once: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user