Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select form id in jquery code?
    text
    copied!<p>I'm trying to disable submit button until some fields are filled. I've found a code working, but I have several forms in my page, so I'd like to select the form affected by the code...</p> <p>html:</p> <pre><code>&lt;form id="form_id1"&gt; &lt;fieldset&gt; &lt;legend&gt;Personal&lt;/legend&gt; Name: &lt;input type="text" size="30" /&gt;&lt;br /&gt; Email: &lt;input type="text" size="30" /&gt;&lt;br /&gt; Date of birth: &lt;input type="text" size="10" /&gt;&lt;br /&gt; Address : &lt;textarea size="30"&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;/fieldset&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;form id="form_id2"&gt; &lt;fieldset&gt; &lt;legend&gt;Personal&lt;/legend&gt; Name: &lt;input type="text" size="30" /&gt;&lt;br /&gt; Email: &lt;input type="text" size="30" /&gt;&lt;br /&gt; Date of birth: &lt;input type="text" size="10" /&gt;&lt;br /&gt; Address : &lt;textarea size="30"&gt;&lt;/textarea&gt;&lt;br /&gt; &lt;/fieldset&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; </code></pre> <p>javascript:</p> <pre><code>$(document).ready(function() { $('input:submit').attr("disabled", true); var textCounter = false; $('input:text, textarea').keyup(check_submit); function check_submit() { $('input:text, textarea, select').each(function() { if ($(this).val().length == 0) { textCounter = true; return false; } else { textCounter = false; } }); $('input:submit').attr("disabled", textCounter); } }); </code></pre> <p>any idea? thanks</p> <hr> <p>Ok, with the code #form_id1 input:submit before all fields it works on jsfiddle. But not on my page... I found that I'm using tinymce for textarea field, and that is the problem. The button is not activated after filling the textarea field! If I remove tinymce, it works! Any idea?</p> <hr> <p>I've found that tinymce is using iframe for displaying its textarea :-(( is there a way to validate that?...</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