PIN Access Control

Simple numeric security. This script prompts the user to enter a specific PIN code before revealing the page content.

The correct PIN is 1234

Copy the Script

<script>
function checkPIN() {
    var pin = "1234";
    var entry = prompt("Please enter the 4-digit PIN:");
    
    while (entry != pin) {
        if (entry === null) return; // User cancelled
        entry = prompt("Incorrect. Please try again:");
    }
    
    alert("Access Granted!");
}
// checkPIN(); // Uncomment to run on load
</script>

Frequently Asked Questions

In this specific script, clicking Cancel will act as a wrong guess and simply re-prompt the user or alert them that access is denied.

No. The PIN is visible in the JavaScript source code. This is suitable for very basic protection (e.g., a child's game page) but not for sensitive data.

Yes. You can add a counter variable (e.g., 'var tries = 0') and break the loop if it exceeds 3 attempts.