If textarea empty then simply do not send the form js

  • return false; with sub, make stop the forwarding of the event (it seems). - DanielOlivo

3 answers 3

 // Обработчик отправки формы $('form').submit(function(){ // Если textarea пустое if(!$(this).find('textarea').val()){ // отменяем отправку return false; } }); 

    You must specify the required attribute in the field.
    Read more here: http://htmlbook.ru/html/input/required

      1. If the form is submitted by the browser itself or by the submit event on the form:

        • Use attribute required (if there are IE users - then only for version 10+)

        • Use the attribute pattern=".+" (Support is worse than that of required , therefore less preferred, and semantically worse)

      2. If the form is sent from a jquery handler, or there are users without support for the above-named attributes, then event.preventDefault(); can be used event.preventDefault(); in the body of the click or submit event handler

      • How to implement it? - BedOmar