Powered by Cellfex RSS Follow me on Spotify

Archive for the ‘jQuery’ Category

How to avoid bots (and not to use caption plugins which suck)… there is a trick that works almost always (well, It uses javascript and they work for me always and i never seen a bot avoiding it). Of course there are users disabling javascript but thats soooo ’90.
Better is to use plain javascript but with jQuery it will be faster [for me to write this]. So install jQuery.

So when creating a block for forms plugin, make it go elsewhere like <form id=”frmGuestbook” action=”http://go/away“>
MAYBE there are still users from ’90ties which use IE5.5 or Netscape Navigator and really have disabled javascript so maybe its a good idea to put a warnign too like <div id=”msgCantWriteGuestbookWithoutJS”>Sorry, you must have javascript to write enabled to write in guestbook</div>

Then, in the html header put this code.
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#msgCantWriteGuestbookWithoutJS').hide();
$('frmGuestbook').attr('action', './put/the/real/link/here');
}
</script>

so what it does – with help of jquery it removes a warning and sets normal action attribute for form. Voila. Spam bot walks in, fills out data and gets redirected to http://go/away. Farewell!

there are other tricks but i will tell a bit later (if you dont figure out yourself). For example CSS and empty field trick – Make a 1×1 pixel  transparent input field and name it “name” so bot will 1000% fill it in. And then when you put the posted data in database, just check for value in “name”. If it is filled in, then it was written by nonhuman (or really small miniperson who sees 1×1 pixel text field as normal text field). So, just ignore the post if “name” is not empty.

Anyway, captions are soooooo 2000….

22 Apr 2010

Avoid spambots and spam in HTML forms.

Author: Edgars | Filed under: HTML, Javascript, jQuery

We all know how great is to make dynamic HTML lists so you may traverse into selections by taking into account what has been selected before. Superduper way would be to use AJAXized calls to server so it takes care of what should be displayed, but what to do if you have already two rendered HTML combo boxes (aka drop-downs) and just must make a JavaScript logic to take care of showing only those options from list 2 that correspond to the selection in list 1. Internet (google) has some examples using JS arrays which totally doesn’t suite me since i prefer “less code – less hassle” principle. And such arrays doesnt fit me since as i said – i have two generated lists and dont want to generate them as arrays and then build up in JavaScript which in my opinion is just an extra step.
Read the rest of this entry »

29 Mar 2010

Dynamic html lists with jQuery

Author: Edgars | Filed under: CSS, HTML, Javascript, Web Development, jQuery