Copy link to clipboard
Copied
Hi everyone,
I have the code below in my news detail layout. To try and combat spam-bots I'm using javascript to insert the action url on key press for the comments form. This type of code works perfectly well on all other forms on the site but for some reason it won't work on a comment form, ie. the action doesn't get inserted.
Just wonderd if anyone could give me any clues?
Thanks in advance.
<form name="catratingform2343" onsubmit="return checkWholeForm2343(this)" method="post">
<div class="columns large-6">
<div class="row collapse">
<div class="small-10 columns">
<input name="FullName" type="text" placeholder="Full Name" />
</div>
<div class="small-2 columns"> <span class="postfix radius"><em class="icon-user"></em></span> </div>
</div>
<div class="row collapse">
<div class="small-10 columns">
<input name="website" type="text" placeholder="Website" />
</div>
<div class="small-2 columns"> <span class="postfix radius"><em class="icon-globe"></em></span> </div>
</div>
<div class="row collapse">
<div class="small-10 columns">
<input placeholder="Email Address" type="text" name="EmailAddress" />
</div>
<div class="small-2 columns"> <span class="postfix radius"><em class="icon-envelope"></em></span> </div>
</div>
</div>
<div class="columns large-6">
<label>
<textarea class="cat_listbox_large" name="Feedback" placeholder="Comment Here"></textarea>
</label>
<label>Enter Word Verification in box below {module_captchav2}</label>
<input class="button radius" type="submit" value="Submit" />
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="/CatalystScripts/ValidationFunctions.js"></script>
<script type="text/javascript"> //<![CDATA[
$( "#catratingform2343" ).on( "keypress", function( event ) {
var action = $("#catratingform2343").attr("action");
if ( typeof(action) === "undefined" || action === null || action === "" ) {
var url = "/RatingProcess.aspx"
var params = "?OID={module_oid}&OTYPE={module_otype}";
$( "#catratingform2343" ).attr("action",url + params);
}
});
function checkWholeForm2343(theForm){var why = "";if (theForm.EmailAddress) if (theForm.EmailAddress.value.length > 0) why += checkEmail(theForm.EmailAddress.value);if (theForm.CaptchaV2) why += isEmpty(theForm.CaptchaV2.value, "Enter Word Verification in box below");if (why != ""){alert(why);return false;}return true;}
//]]> </script>
</form>
i thnk you forgot the selector on the form id="catratingform2343"
Copy link to clipboard
Copied
i thnk you forgot the selector on the form id="catratingform2343"
Copy link to clipboard
Copied
Thanks so much. I can't believe I did that - I do it all the time. Much appreciated.