avoid to input whitespace or spaces on first input

This commit is contained in:
srgooglo 2022-10-12 14:06:49 +02:00
parent f3239a6629
commit c42607eee6
2 changed files with 10 additions and 0 deletions

View File

@ -33,6 +33,11 @@ export default (props) => {
return setValue(null)
}
// if post only have whitespaces, dont allow to submit
if (e.target.value.trim() === "") {
return setValue("")
}
return setValue(String(e.target.value))
}

View File

@ -144,6 +144,11 @@ export default (props) => {
}
const onChangeMessageInput = (event) => {
// if the fist character is a space or a whitespace remove it
if (event.target.value[0] === " " || event.target.value[0] === "\n") {
event.target.value = event.target.value.slice(1)
}
updatePostData({
message: event.target.value
})