A
A
Alexander Shtang2015-10-29 13:19:00
JavaScript
Alexander Shtang, 2015-10-29 13:19:00

How to prevent sending an empty field to the server?

There is a comment attribute on the route object, for example. How to prohibit sending an empty, not filled, field to the Back? (despite the fact that the filled textarea needs to be sent, of course)
Angular || React || Native?
And that it at each sending there develops and clutters up a DB.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Shtang, 2015-11-20
@Enclave88

Turned out to be just = null

D
Dmitry Ermolaev, 2015-10-29
@iusfof

document.querySelector('#form').onsubmit = function(){
  if (!document.querySelector('#textarea').value) {
    return false;
  }     
}

or
document.querySelector('#form').onsubmit = function(event){
  if (!document.querySelector('#textarea').value) {
    event.preventDefault()
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question