Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Foros del Web</title>
</head>
<body>
    <section id="foo">
        <div>
            <label>Input 1:</label>
            <input type="text" maxlength="1" />
        </div>
        <div>
            <label>Input 2:</label>
            <input type="text" maxlength="1" />
        </div>
        <div>
            <label>Input 3:</label>
            <input type="text" maxlength="1" />
        </div>
    </section>
</body>
</html>
 
/**
 * Evitar repetición de valores
 *
 * @author Alexis88
 */
var noRepeat = {
    init: function(){
        var values = [];
        
        noRepeat.inputs = this.querySelectorAll("#foo input");
        noRepeat.parent = this.querySelector("#foo");
        
        noRepeat.parent.addEventListener("keypress", function(e){
            var input = e.target;
                        
            if (values.indexOf(e.key) > -1) e.preventDefault();
            
            if (e.key.length) values.push(e.key);
        }, false);
    }
};
document.addEventListener("DOMContentLoaded", noRepeat.init, false);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
Alexis88pro
0viewers