mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +00:00
Prevent pressing submit if the Markdown widget is empty
This commit is contained in:
parent
0011f4c7b0
commit
e932abfa74
@ -175,24 +175,25 @@
|
|||||||
let parentDiv = textarea.parentElement
|
let parentDiv = textarea.parentElement
|
||||||
let submitPressed = false
|
let submitPressed = false
|
||||||
|
|
||||||
function checkMarkdownInput() {
|
function checkMarkdownInput(e) {
|
||||||
// an attribute is null if it does not exist, else a string
|
// an attribute is null if it does not exist, else a string
|
||||||
let required = textarea.getAttribute('required') != null
|
let required = textarea.getAttribute('required') != null
|
||||||
let length = textarea.value.trim().length
|
let length = textarea.value.trim().length
|
||||||
|
|
||||||
if (required && length == 0) {
|
if (required && length == 0) {
|
||||||
parentDiv.style.boxShadow = 'red 0px 0px 1.5px 1px'
|
parentDiv.style.boxShadow = 'red 0px 0px 1.5px 1px'
|
||||||
|
e.preventDefault()
|
||||||
} else {
|
} else {
|
||||||
parentDiv.style.boxShadow = ''
|
parentDiv.style.boxShadow = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
submit.addEventListener('click', () => {
|
submit.addEventListener('click', (e) => {
|
||||||
if (!submitPressed) {
|
if (!submitPressed) {
|
||||||
easymde.codemirror.on('change', checkMarkdownInput)
|
easymde.codemirror.on('change', checkMarkdownInput)
|
||||||
}
|
}
|
||||||
submitPressed = true
|
submitPressed = true
|
||||||
checkMarkdownInput()
|
checkMarkdownInput(e)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user