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
// Обработчик отправки формы $('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
|
If the form is submitted by the browser itself or by the
submitevent 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 ofrequired, therefore less preferred, and semantically worse)
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 usedevent.preventDefault();in the body of theclickorsubmitevent handler
- How to implement it? - BedOmar
|