title: How to validate forms in JS when the form name changes dynamically?
body: <p>I have a profile page in php for students of a school.</p>
  
  <p>Each single profile page loops over the mysql database to get each course that the student is enrolled in. It can be several courses.</p>
  
  <p>For each course there is a small form that allows me to fill a specific field to put the final grade by hand for each course.</p>
  
  <p>My problem is that I want to target each form in javascript in order to validate that when I click "submit" the field is not empty.</p>
  
  <p>It does work (in the sense that it does the validation), but it targets the first form, because I'm using the form's name, which is the same for every course.</p>
  
  <h2>This is my form:</h2>
  
  <pre><code>&lt;form class="form-inline" name="formEmisionCertificado" action="/certificados/emitirCertificado.php" method="POST"&gt;
  &lt;input type="text" name="fechaFinalizacionTexto" id="fechaFinalizacionTexto"&gt;
  &lt;button type="submit" class="btn btn-primary btn-sm"&gt;emitir certificado&lt;/button&gt;   
  &lt;/form&gt;
  </code></pre>
  
  <h2>And here is my validation:</h2>
  
  <pre><code>$("form[name='formEmisionCertificado']").validate({
      errorClass:'alert alert-danger',
      rules: {
                fechaFinalizacionTexto: {
                  required: true
                }
              },
      messages:{
                fechaFinalizacionTexto: {
                  required: "Falta la fecha de aprobación del curso"
                }                  
      }
    });
  </code></pre>
  
  <p>My problem is that every form is going to be called "formEmisionCertificado", so I thought to attach to every form name the course id in PHP, so every form name is like "<em>formEmisionCertificado23</em>", "<em>formEmisionCertificado95</em>", "<em>formEmisionCertificado112</em>" and so on.</p>
  
  <p>I know very little of JS, how may I target each form when the names are different? Is there a better way to do it?</p>