Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My new feature - captcha on login #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions dist/auth-login.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,51 @@

<link rel="shortcut icon" href="assets/images/favicon.svg" type="image/x-icon">
<link rel="stylesheet" href="assets/css/app.css">
<style>
.capbox {
background: #3483eb;
background: linear-gradient(to right, #3483eb, #76a7e8);
border: #0551b5 0px solid;
border-width: 2px 2px 2px 20px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
display: inline-block;
padding: 5px 8px 5px 8px;
border-radius: 4px 4px 4px 4px;
}

.capbox-inner {
font: bold 12px arial, sans-serif;
color: #000000;
background:rgba(255,255,255,0.30); /* SEMI TRANSPARENT BACKGROUND */
margin: 0px auto 0px auto;
padding: 3px 8px 5px 10px;
border-radius: 4px;
display: inline-block;
vertical-align: middle;
}

#CaptchaDiv {
color: #000000;
font: normal 25px Impact, Charcoal, arial, sans-serif;
font-style: italic;
text-align: center;
vertical-align: middle;
background-color: #FFFFFF;
user-select: none;
display: inline-block;
padding: 3px 14px 3px 8px;
margin-right: 4px;
border-radius: 4px;
}

#CaptchaInput {
border: black 2px solid;
margin: 3px 0px 1px 0px;
width: 105px;
}
</style>
</head>

<body>
Expand Down Expand Up @@ -59,6 +104,13 @@ <h3>Sign In</h3>
</div>
</div>
<div class="clearfix">
<div class="capbox">
<div id="CaptchaDiv">58617</div>
<div class="capbox-inner">
<input type="hidden" id="txtCaptcha" value="58617">
<input type="text" name="CaptchaInput" id="CaptchaInput" size="15"><br>
</div>
</div>
<button class="btn btn-primary float-end">Submit</button>
</div>
</form>
Expand All @@ -80,6 +132,52 @@ <h3>Sign In</h3>
</div>

</div>
<script>
// Captcha Script

function checkform(theform){
var why = "";

if(theform.CaptchaInput.value == ""){
why += "- Please Enter CAPTCHA Code.\n";
}
if(theform.CaptchaInput.value != ""){
if(ValidCaptcha(theform.CaptchaInput.value) == false){
why += "- The CAPTCHA Code Does Not Match.\n";
}
}
if(why != ""){
alert(why);
return false;
}
}

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 code = a + b + c + d + e;
document.getElementById("txtCaptcha").value = code;
document.getElementById("CaptchaDiv").innerHTML = code;

// Validate input against the generated number
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('CaptchaInput').value);
if (str1 == str2){
return true;
}else{
return false;
}
}

// Remove the spaces from the entered and generated code
function removeSpaces(string){
return string.split(' ').join('');
}
</script>
<script src="assets/js/feather-icons/feather.min.js"></script>
<script src="assets/js/app.js"></script>

Expand Down