Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>ANSWER</h2> <p><strong><a href="http://jsfiddle.net/BQQhS/6/" rel="nofollow">jsFiddle Demo</a></strong></p> <hr> <p><strong>HTML</strong></p> <pre><code>&lt;form action="#"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;label for="reporte_f1"&gt;Motivo del reporte: &lt;br /&gt; &lt;/label&gt; &lt;textarea id="reporte_f1" rows="7" cols="50"&gt;&lt;/textarea&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div&gt; &lt;input type="submit" class="reporta" value="Reportar" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <hr> <p><strong>JS</strong></p> <pre><code>function reportar(v_id, motivo, razon) { $('.reporta').html('&lt;img src=\"img/cargando2.gif\" width=\"30px\" height=\"30px\"/&gt;'); $.ajax({ url: "forms.php?form=10", data: { v_id: v_id, motivo: motivo, razon: razon }, type: "POST", success: function (response) { $(".reportar[rel]").overlay().close(); $('#dialogo').fadeIn(250); $('#dialogo').html("&lt;ul&gt;&lt;li class='ack'&gt;El reporte ha sido enviado correctamente&lt;/li&gt;&lt;/ul&gt;"); setInterval(function () { $('#dialogo').fadeOut(400); }, 3000); }, error: function (xhr, ajaxOptions, thrownError) { alert("Ha ocurrido un error al cargar los datos"); } }); } $(function () { $('.reporta').click(function () { //.reporta is the submit field of the form var motivo = $('#reportar select').val(); var razon = $('#reportar textarea').val(); reportar(v_id, motivo, razon); //Ajax call }); //creation of LiveValidation object var reporte_f1 = new LiveValidation('reporte_f1', { validMessage: "Gracias!", wait: 300 }); reporte_f1.add(Validate.Presence, { failureMessage: "Por favor, introduzca algo" }); //The regex pattern here has to be matched reporte_f1.add(Validate.Format, { pattern: /^\w+$/i, failureMessage: "Por favor, introduzca un mensaje válido" } ); }); </code></pre> <hr> <p><strong>Note</strong></p> <p>I found this out by looking at the following <a href="http://livevalidation.com/examples" rel="nofollow">example</a>.</p> <p>Also taken from the following <a href="http://livevalidation.com/examples#exampleForms" rel="nofollow">example</a></p> <blockquote> <p>When a LiveValidation object is instantiated, if it finds it is a child of a form, it will automatically attach itself to the submit event of the form, so when it is submitted, validation on all the LiveValidation objects inside it will be performed automatically. If any of the validations fail it will stop the form submitting (this of course only works when javascript is on in the users bowser, so be sure to do some validation on the server too!). You can also specify the onlyOnSubmit option to be true when you create the LiveValidation object to make it only validate when the form is submitted. This is demonstrated in the following example. Note also that the email field has no validation that it is present, therefore if this is not filled in the form will still be valid, as it will be treated as an optional field. In this example the outcome is overidden if it is valid as this page has nowhere to submit to - instead of submitting, it will alert that it is valid, in real life it will just carry on submitting if valid.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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