Note that there are some explanatory texts on larger screens.

plurals
  1. POModify a jQuery script to remove a function (without breaking it...)
    primarykey
    data
    text
    <p>I've installed a nice little jQuery mailer script that contains a required field (Subject) I don't want, and would like to remove it. First I simply removed the html, forgetting the verification and got an error. Then I tried to remove the part of the script that verifies if a Subject (a <code>&lt;select&gt;</code>) was chosen, but got an error, and am asking for help, now. Here's the script:</p> <p>html:</p> <pre><code>&lt;form id="contact-form" name="contact-form" method="post" action="submit.php"&gt; &lt;table width="100%" border="0" cellspacing="0" cellpadding="5"&gt; &lt;tr&gt; &lt;td width="25%" style="text-align:right;"&gt;&lt;label for="name"&gt;Name&lt;/label&gt;&lt;/td&gt; &lt;td width="65%" style="text-align:left;"&gt;&lt;input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="&lt;?=$_SESSION['post']['name']?&gt;" /&gt;&lt;/td&gt; &lt;td width="10%" id="errOffset" style="text-align:right;"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="text-align:right;"&gt;&lt;label for="email"&gt;Email&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="validate[required,custom[email]]" name="email" id="email" value="&lt;?=$_SESSION['post']['email']?&gt;" /&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="subject"&gt;Subject&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="subject" id="subject"&gt; &lt;option value="" selected="selected"&gt; - Choose -&lt;/option&gt; &lt;option value="Question"&gt;Question&lt;/option&gt; &lt;option value="Business proposal"&gt;Business proposal&lt;/option&gt; &lt;option value="Advertisement"&gt;Advertising&lt;/option&gt; &lt;option value="Complaint"&gt;Complaint&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" style="text-align:right;"&gt;&lt;label for="message"&gt;Message&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;textarea name="message" id="message" class="validate[required]" cols="35" rows="5"&gt;&lt;?=$_SESSION['post']['message']?&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;td valign="top"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;label for="captcha"&gt;&lt;?=$_SESSION['n1']?&gt; + &lt;?=$_SESSION['n2']?&gt; =&lt;/label&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /&gt;&lt;/td&gt; &lt;td valign="top"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top"&gt;&amp;nbsp;&lt;/td&gt; &lt;td colspan="2"&gt;&lt;input type="submit" name="button" id="button" value="Submit" /&gt; &lt;input type="reset" name="button2" id="button2" value="Reset" /&gt; &lt;?=$str?&gt; &lt;img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>And the script from where I'd like to remove the 'Subject' verification function:</p> <pre><code> $(document).ready(function(){ $('#contact-form').jqTransform(); $("button").click(function(){ $(".formError").hide(); }); var use_ajax=true; $.validationEngine.settings={}; $("#contact-form").validationEngine({ inlineValidation: false, promptPosition: "centerRight", success : function(){use_ajax=true}, failure : function(){use_ajax=false;} }) $("#contact-form").submit(function(e){ if(!$('#subject').val().length) { $.validationEngine.buildPrompt(".jqTransformSelectWrapper","* This field is required","error") return false; } if(use_ajax) { $('#loading').css('visibility','visible'); $.post('submit.php',$(this).serialize()+'&amp;ajax=1', function(data){ if(parseInt(data)==-1) $.validationEngine.buildPrompt("#captcha","* Wrong verification number!","error"); else { $("#contact-form").hide('slow').after('&lt;h1&gt;Thank you!&lt;/h1&gt;'); } $('#loading').css('visibility','hidden'); } ); } e.preventDefault(); }) }); </code></pre> <p>I'd tried removing the area indicated in the above code. The script has an 'are you human' simple math function, and after removing the code, I got an alert stating the answer to the simple math was wrong despite the fact that it was correct.</p>
    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.
 

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