Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery detect empty form how to?
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/6056705/empty-field-validation-in-jquery">empty field validation in jquery</a> </p> </blockquote> <p>I need to detect if a form is empty or not. I've already client side validation, with mandatory fields and not mandatory, when there is one mandatory field or more, and this is (these are) empty, post button launches client-side validation errors, and this is fine. When they all aren't mandatory i just need to disable the post button till I insert a value, enabling the post button when i write something. But if i delete the values, i can't detect if the form is empty or not to re-disable the button!</p> <pre><code>$('#form .my_field').each(function() { $(this).data('oldVal', $(this).val()); $(this).bind("propertychange keyup input paste change blur", function(event) { if ($(this).data('oldVal') != $(this).val()) { $('#post_button').button({ disabled: false }); } }); }); </code></pre> <p>with this bind i can detect when i write in a casual form field, but i've no clues how to find if every field is clean. I've tried many roads, but they lead me to dead end. Maybe is a 10-hours programming issue :) I've tried some kind of </p> <pre><code> if ($(this).val()=='') </code></pre> <p>, but for some fields (datapicker for example) does not work (i can have too multiselects ----> :option selected)</p> <p>I suppose i've to bind to the same events to a (if empty set a boolean flag) and check all the boolean flags to determine if they're all true (or false)..any hints?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload