How to create capcha code using js ?

in #programming8 years ago

How to create Capcha Code using java Script-

Code to create Capcha Code given Below:

<script language="javascript">
    var a = Math.ceil(Math.random() * 9) + '';
    var b = Math.ceil(Math.random() * 9) + '';
    var c = Math.ceil(Math.random() * 9) + '';
    var d = Math.ceil(Math.random() * 9) + '';
    var e = Math.ceil(Math.random() * 9) + '';
    var f = Math.ceil(Math.random() * 9) + '';
    var g = Math.ceil(Math.random() * 9) + '';
    var h = Math.ceil(Math.random() * 9) + '';
    var code = a + b + c + d + e + f + g + h;
    document.getElementById("numcode").value = code;

    function ValidCaptcha() {
        var str1 = removeSpaces(document.getElementById('numcode').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
        if (str1 == str2) {
            return true;
            alert(str1);
        } else {
            return false;
        }
    }

    function removeSpaces(string) {
        return string.split(' ').join('');
    }

Enjoy!

Good Luck!

Sort:  

thats pointless :D The capcha is to prevent automated requests (bots) to the server. your code will just ask the real user but never the "bad guy"

Coin Marketplace

STEEM 0.32
TRX 0.26
JST 0.039
BTC 94921.11
ETH 3381.56
USDT 1.00
SBD 3.33