Additional whitespace validation
This commit is contained in:
parent
9318d28a21
commit
66aefe3d2d
@ -193,10 +193,19 @@ form.addEventListener('submit', (e) => {
|
|||||||
input.focus();
|
input.focus();
|
||||||
|
|
||||||
// Disable form
|
// Disable form
|
||||||
if (input.value === '' || input.value === ' ')
|
for (let index = 0; index < input.value.length; index++) {
|
||||||
return alert('Your message is blank');
|
if (input.value[index] == ' ') {
|
||||||
else if (input.value[0] === ' ')
|
console.log('true');
|
||||||
return alert('Delete the space at the beggining');
|
|
||||||
|
input.value = input.value.slice(index + 1);
|
||||||
|
if (!input.value.slice(index + 1)) return;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('input value: ' + input.value);
|
||||||
|
if (input.value === '') return console.log('input pusty');
|
||||||
|
|
||||||
button.setAttribute('disabled', 'disabled');
|
button.setAttribute('disabled', 'disabled');
|
||||||
|
|
||||||
socket.emit('message', input.value, (error) => {
|
socket.emit('message', input.value, (error) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user