-
-
Save sooop/e0d99d2f20ccdce97b57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<script src="./lib/mithril.min.js"></script> | |
<script src="./js/password.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var password = {}; | |
password.controller = function() { | |
this.description = m.prop(""); | |
this.validate = function() { | |
var t = this.description(); | |
var s = t.match(/^(?=\w{6,}$)(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).*/); | |
if (s) { | |
return true; | |
} | |
return false; | |
} | |
} | |
password.view = function(ctrl) { | |
return m('html', [m('body', [m('div', [ | |
m('input[type=text]', { | |
onkeyup: m.withAttr('value', ctrl.description), | |
value: ctrl.description(), | |
style: { | |
backgroundColor: ctrl.validate() ? "green" : "red" | |
} | |
}), | |
m('input[type=text]', { | |
readonly: true, | |
value: ctrl.validate() ? "Pass!" : "Fail!", | |
style: { | |
color: ctrl.validate() ? "black" : "red", | |
} | |
}) | |
])])]); | |
} | |
m.module(document, password) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment