Captcha is a one of the very useful utility for website data security. it will be strickly prohibited invalid form submission in the website. in this post i am explain that how to create MotionCaptcha using jQuery.this is a very simple to implement in your web application and it looks like drawing a user has to draw given sketch. below given live demo and example but only subscriber users can download other user can see only demo.
<link rel="stylesheet" href="jquery.motionCaptcha.0.2.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.motionCaptcha.0.2.js" ></script>
jQuery motionCPTCHA initialize:
<script type="text/javascript">
jQuery(document).ready(function($) {
// Do the biznizz:
$('#mc-form').motionCaptcha({ // Form id to append shapes
shapes: ['triangle', 'x', 'rectangle', 'circle', 'check', 'zigzag', 'arrow', 'delete', 'pigtail', 'star'] // list of shapes which we have included in file.
});
});
</script>
CSS to make drawing area looks nice:
<style>
form {
width: 440px;
display: block;
text-align:left;
margin: 20px auto;
}
input,
textarea {
font-family:"Lucida Grande", sans-serif;
font-size: 13px;
font-weight: bold;
display: block;
border: 0;
outline:0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 0 0 5px rgba(0,0,0,0.1), inset 0 1px 1px rgba(0,0,0,0.3);
-moz-box-shadow: 0 0 0 5px rgba(0,0,0,0.1), inset 0 1px 1px rgba(0,0,0,0.3);
box-shadow: 0 0 0 5px rgba(0,0,0,0.1), inset 0 1px 1px rgba(0,0,0,0.3);
padding: 9px 12px;
margin:0 0 20px;
}
/* MotionCAPTCHA canvas */
#mc-canvas {
margin:0 auto 20px;
padding:1px;
display: block;
border: 4px solid #433e45;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
/* Red border when invalid */
#mc-canvas.mc-invalid {
border: 4px solid #aa4444;
}
/* Green border when valid */
#mc-canvas.mc-valid {
border: 4px solid #44aa44;
}
</style>
All together:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>How to prevent spammers with motion CAPTCHA using jQuery | easyscript4u.blogspot.in</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<link rel="stylesheet" href="jquery.motionCaptcha.0.2.css?ez_orig=1"/>
<style>
form {
width: 440px;
display: block;
text-align:left;
margin: 20px auto;
}
input,
textarea {
font-family:"Lucida Grande", sans-serif;
font-size: 13px;
font-weight: bold;
display: block;
border: 0;
outline:0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 0 0 5px rgba(0,0,0,0.1), inset 0 1px 1px rgba(0,0,0,0.3);
-moz-box-shadow: 0 0 0 5px rgba(0,0,0,0.1), inset 0 1px 1px rgba(0,0,0,0.3);
box-shadow: 0 0 0 5px rgba(0,0,0,0.1), inset 0 1px 1px rgba(0,0,0,0.3);
padding: 9px 12px;
margin:0 0 20px;
}
/* MotionCAPTCHA canvas */
#mc-canvas {
margin:0 auto 20px;
padding:1px;
display: block;
border: 4px solid #433e45;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
/* Red border when invalid */
#mc-canvas.mc-invalid {
border: 4px solid #aa4444;
}
/* Green border when valid */
#mc-canvas.mc-valid {
border: 4px solid #44aa44;
}
</style>
</head>
<body>
<h2>How to prevent spammers with motion CAPTCHA using jQuery example By easyscript4u.blogspot.in. => <a href="http://www.phpgang.com/">Home</a> | <a href="/">More Demos</a></h2>
<form action="#" method="post" id="mc-form">
<div id="mc">
<p>Please draw the shape in the box to submit the form: (<a onclick="window.location.reload()" href="#" title="Click for a new shape">new shape</a>)</p>
<canvas id="mc-canvas">
Your browser doesn't support the canvas element - please visit in a modern browser.
</canvas>
<input type="hidden" id="mc-action" value=""/>
</div>
<p><input disabled="disabled" autocomplete="false" type="submit" value="Submit"></p>
</form>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.motionCaptcha.0.2.js" ></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Do the biznizz:
$('#mc-form').motionCaptcha({
shapes: ['triangle', 'x', 'rectangle', 'circle', 'check', 'zigzag', 'arrow', 'delete', 'pigtail', 'star']
});
});
</script>
</body>
</html>
above given complate code will work as a MotionCaptcha working in demo and you can also download by clicking download button.
if you have any query than you can freely contact at Email : easyscript4you@gmail.com
0 comments:
Post a Comment