Skip to content

Instantly share code, notes, and snippets.

@szilardhuber
Created April 22, 2015 08:52
Show Gist options
  • Save szilardhuber/3971bfc2cd8f17b6333f to your computer and use it in GitHub Desktop.
Save szilardhuber/3971bfc2cd8f17b6333f to your computer and use it in GitHub Desktop.
Javascript PIN checker for Kadosa :)
<!doctype html>
<html>
<head>
</head>
<body>
<form onsubmit="return formSubmitted()">
<label for="pin">Pin code</label>
<input id="pin" type="password" onkeypress="return inputChange()"/>
<input type="submit"/>
</form>
<script type="text/javascript" src="./index.js"></script>
<script type="text/javascript" src="./index2.js"></script>
</body>
</html>
var userPIN = 2345;
function formSubmitted() {
var enteredPIN = parseInt(document.getElementById("pin").value);
if (enteredPIN > 0 && enteredPIN < 9999) {
if (enteredPIN == userPIN) {
alert("This PIN is valid");
return true;
}
else {
alert("This is not your PIN");
return false;
}
}
alert("Please enter valid PIN");
return false;
}
function inputChange() {
var content = document.getElementById("pin").value;
return content.length < 4;
}
function cica() {
return 42;
}
console.log(cica());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment